JavaScript - Priviate Message Count?
Hee guys,
I've got a little bit of a problem on my hand. Someone has asked me to help them on a FREE forum host. You have no access to PHP or SQL or anything like that. Just the templates, but even those are really messy! Now on the navagation bar there a PM section (obviously) but the wording they have used is very long and ugly. I was wondering if it would be possible to change the wording whilst still having it show the amount of PM's that you have. If you need anymore information just ask, but I really hope someone can help Similar TutorialsHi, I am not a Javascript programmer and I am facing some barriers. Maybe some of you could help me. I would need a script that can be used to count down until any given date with hour, minutes and seconds. For example: Quote: September 10, 2009 16:02:00 Bob Kuspe I've been looking everywhere for a script that counts up from 1 to 10, but can't find anything. I even searched the forums. Basically just something that starts from 1 and then replaces itself with 2, and so on. Thanks! hi i am new to javascript. i make a mcq quiz website in one of server side script. now for that website i want to make count down timer so when that quiz starts the user will have 5 minutes to complete that quiz if use does not able to complete quiz in given time then quiz should disable and shows the user score how can i achieve this Deleted
I would like to count how many duplicate values I have in an array. My below attempt doesnt count the duplicate values: Code: var ct = 0; for(var i = 0;i < myArray.length;i++) { var myData = getData[i].city; if(myData == myData) { ct++; } alert("Total Count = " + ct); } Please advise the best way to do this. Hi, I want to do a redirect count so that the user can see the count going down. for example, I want them to be able to see the following. You will be redirected in 5 seconds. The user should be able to see the count going down from 5 to 4 to 3 to 2 to 1 and then they are redirected. I can get the page to redirect after 5 seconds but I want the user to be able to see it count down. Thanks in advance for your help Hi all new guy on the block here, I've got a website, and I want to add a welcoming message which hovers on a certain part of the page which only loads for the visitor for the first time they login, and won't again(presumably cookies used). And says something like "adjust your settings here.." I don't want it to be an external popup but something that loads on the page in a certain area, defined by me (PX-pixle reference) I think i nutted something out in a bit of PHP, this is what i've got so far PHP Code: <?php if (firstLogin()){ genSpecial(***load jquerie or css etc***); } else{ genRegular(); } ?> can anyone help me figure out how to make this all work and load a box from jquerie or something similar? thanks David i have multiple customers in my company and i want to send an SMS to the mobile (cell phone) of the customer that he must pay the renewals fee's durng 2 weeks.. so i send to him an e-mail and at the same time i send for him an SMS message to his phone to ensure that he will read the message that he must pay the fee's. i dont know if there is a module that can make this idea or i must buy a product or register into a website to make this module... thnx alot I was wondering if there was an easy way to configure a message box to resemble that of a login form. It would preferably have two text fields for username/password and OK and Cancel buttons as well. I currently have a normal login form on my website designed using PHP but it does not figure into what we need to do now. I'm not sure about going about this and I have tried looking for quite sometime for an example of this but cannot find one.
Hello all, I'm trying to write a simple script in JS that will show a message for each day of the week. I have searched in your forums and other places but sadly I keep failing. Thank you for helping a newb. Code: <script type="JavaScript"> function showMessage() { var d = new Date(); var day = d.getDay(); // Note: Sunday=0, Monday=1, etc... switch( true ) } case ( day == 6 ) : { document.write("Today is saturday!") } case ( day == 5 ) : { document.write("Today is friday!") } case ( day == 4 ) : { document.write("Today is thursday!") } case ( day == 3 ) : { document.write("Today is wednesday!") } case ( day == 2 ) : { document.write("Today is tuesday!") } case ( day == 1 ) : { document.write("Today is monday!") } case ( day == 0 ) : { document.write("Today is sunday!") } } } </script> Hi Guys, I have a javascript, which counts the specified words.. I want javascript to count some of the html tags and symbols when i enter a html code in the textarea.. - the below searchwords are not functioning properly. http://(space) http:/(space) etc... (no spaces are searching) - www. (.(dot) is not searching, also when i enter wwww(4 times) in the textarea it shows www. as count 1) - i can't enter the below symbols in searchwords array [ < ' ? I thank once again Bullant for helping me on the below script... But i am trying to fix my above issue and i couldn't.. :( Please help me out guys... Here is my Code... Code: <html> <head> <title>Word Count</title> <script type = "text/javascript"> function searchForWords(){ document.getElementById('resultsContainer').innerHTML = ''; var txt = document.getElementById('txtMsg').value; var strWords = document.getElementById('txtSearchWords').value; var searchWordsTokens = strWords.split(' '); var searchWords = ['href','LINK_ID','mailto','src="','src= ','src =','.jpg','.gif','.png','www','www.','http','http:// ','http:/ ','http: ','http ',' http',' "','@','amp;','TBD']; for(i=0; i < searchWordsTokens.length; i++){ if(searchWordsTokens[i].length > 0){searchWords.push(searchWordsTokens[i]);} //remove spaces between words } var results = [],matches; for(i=0; i < searchWords.length; i++){ var regex = new RegExp('\\b'+searchWords[i]+'\\b','gi'); matches = txt.match(regex); results[searchWords[i]] = (matches)? matches.length : 0; } //output results var str = ''; for(var i in results){ str += i+'--'+results[i]+'<br />'; } document.getElementById('resultsContainer').innerHTML = str; } window.onload=function(){ document.getElementById('form_submit').onclick=searchForWords; } </script> </head> <body> <table> <tr><td align="center"> <form id="contact_form"><h4>Paste your HTML Code he </h4> <p><label class="form_label" for='message'></label> <textarea rows="20" cols="60" id="txtMsg"></textarea> </p> <div> <input type="text" id="txtSearchWords"/> </div> <p><input id='form_submit' type="button" value="Check for Counts"></p> <div><p><input id='form_submit' type="reset" value="Clear"></p></div> <div id="resultsContainer"></div> </form><br /></td> </table> </body> </html> Hi I'm looking for ways to limit the textarea input, I dont want people to enter hundreds of lines cause, i only want them to enter max. 10 lines. I've looked at several javascripts (cause the problem only can be solved by javascript), and came up with this script: http://javascript.internet.com/forms...-textarea.html . It works great and even has a counter how many characters are left to type in. However when I copy paste something, the 'counter' doesnt adjust right away...it does when I try to type in something extra though. Is it possible to make the counter adjust automaticly whenever there is pasted ? I guess you guys have to test to see what I mean. Thanks in advance !! I have a js counter which keeps track of how many chars are in a field on an asp form. When the user clicks a button further down in the form, the form generates more fields. This also causes the js counter to reset to its original value, as the page is 'reloading' in a way. How can I check this value and keep it the same when the user clicks this button? I am including the code I have, if anyone has any ideas/suggestions thanks javascript Code: <asp:Content ID="Content1" ContentPlaceHolderID="headContent" runat="server"> <script type="text/javascript"> //limit of chars var lim = 128; function count(a) { //difference count var dif = lim - a.value.length; while (dif < 0) { a.value = a.value.replace(/.$/, '') dif = lim - a.value.length; } //display difference count document.getElementById('myspan').firstChild.data = dif; } </script> counter in code Code: <asp:TextBox ID="txtHeadline" runat="server" Width="600px" MaxLength="128" CssClass="VariableText" onkeyup="count(this)"></asp:TextBox> </td> <td valign="middle" width="160px"> <asp:Label ID="Label14" runat="server" Font-Bold="True" Font-Names="Tahoma" Font-Size="8pt" Text="Characters Remaining: " Width="130px" CssClass="LABEL" Height="16px"></asp:Label> <span id="myspan" Font-Names="Tahoma" Font-Size="8pt">128</span> button Code: <asp:Button ID="btnInitializeTemplate" runat="server" OnClick="btnInitializeTemplate_Click" Text="Initialize Template" CssClass="LABEL" /> i have tried Code: <asp:Button ID="btnInitializeTemplate" runat="server" OnClientClick="return count(document.getElementById('txtHeadline'));" OnClick="btnInitializeTemplate_Click" Text="Initialize Template" CssClass="LABEL" /> it compiles but the value remains reset. any advice on what im doing wrong? Hi, I have a JavaScript function which counts the number of checkboxes in a form, it then counts the number of checked checkboxes, it then calculates a percentage based on the number of checkboxes checked. The problem I have is that if there is only one checkbox in the form (record from the db) then the JS function does not work. Code: //function to check total number of GREEN CheckBoxes checked function countChecksGreen(form) { //initialize total count to zero var totalChecked = 0; //get total number of CheckBoxes in form var chkBoxCount = examsetting.checkboxgreen.length; //loop through each CheckBox for (var i = 0; i < chkBoxCount; i++) { //check the state of each CheckBox if (eval("document.examsetting.checkboxgreen[" + i + "].checked") == true) { //it's checked so increment the counter totalChecked += 1; } } //return the number of checked var greenElement = document.getElementById('green'); var green = greenElement.innerHTML; var percentage = totalChecked/<?php echo $exam['questions']; ?>*100; greenElement.innerHTML = Math.round(percentage*10)/10; } Any help would be appreciated. Hi, I am new here and am hoping for some guidance or a solution. Any help is greatly appreciated. I have a total count in a shopping cart stored from PHP as a cookie. I.E. compare[233], compare[324] (where the id is the item ID). I want to update the count of items in the cart in real time, so when the visitor clicks "Add", the count will update without reloading the page. Currently, I can get PHP to count the cookies, but not JS. The problem that I am having is that if the items are 7, and an item is added it will go to 8 correctly, if another item is added it goes to 14, not 9. This is the code that I have so far: Code: <?php $saved_ct = $number_of_items_already_in_cart; // # of cookies found or 'compare' I.E. 7 ?> <script type="text/javascript"> function increase(){ var i=<?php echo "$saved_ct"; ?>; i++; document.getElementById('i').innerHTML= + i; } </script> Cart: (<b id=\"saved_ct\">{$saved_ct}</b>) --- Item: <a href=\"#\" id=\"{$id}\" onclick=\"increase();return false\">Add to basket</a> The clock should be counting up from January 27, 2012 03:26:00, but for some reason its reading as 3 days having passed instead of the 5 days...My thoughts are that the mistake is in this section of code, because it seems to have counted January as 29 days instead of 31 Code: function CountUp(initDate, id){ * * this.beginDate = new Date(initDate); * * this.countainer = document.getElementById(id); * * this.numOfDays = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; * * this.borrowed = 0, this.years = 0, this.months = 0, this.days = 0; * * this.hours = 0, this.minutes = 0, this.seconds = 0; * * this.updateNumOfDays(); * * this.updateCounter(); } * CountUp.prototype.updateNumOfDays=function(){ * * var dateNow = new Date(); * * var currYear = dateNow.getFullYear(); * * if ( (currYear % 4 == 0 && currYear % 100 != 0 ) || currYear % 400 == 0 ) { this.numOfDays[1] = 29; } But having no experience with Java, this is just a guess...Here's ALL the other info you could need... Here's the Web address the Clock is on: http://nvctruth.com/majorgale/ (i've got to figure out the background on a separate day) And Here is the FULL Code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>JavaScript CountUp Timer - Praveen Lobo</title> <script type="text/javascript"> function CountUp(initDate, id){ * * this.beginDate = new Date(initDate); * * this.countainer = document.getElementById(id); * * this.numOfDays = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; * * this.borrowed = 0, this.years = 0, this.months = 0, this.days = 0; * * this.hours = 0, this.minutes = 0, this.seconds = 0; * * this.updateNumOfDays(); * * this.updateCounter(); } * CountUp.prototype.updateNumOfDays=function(){ * * var dateNow = new Date(); * * var currYear = dateNow.getFullYear(); * * if ( (currYear % 4 == 0 && currYear % 100 != 0 ) || currYear % 400 == 0 ) { * * * * this.numOfDays[1] = 29; * * } * * var self = this; * * setTimeout(function(){self.updateNumOfDays();}, (new Date((currYear+1), 1, 2) - dateNow)); } * CountUp.prototype.datePartDiff=function(then, now, MAX){ * * var diff = now - then - this.borrowed; * * this.borrowed = 0; * * if ( diff > -1 ) return diff; * * this.borrowed = 1; * * return (MAX + diff); } * CountUp.prototype.calculate=function(){ * * var currDate = new Date(); * * var prevDate = this.beginDate; * * this.seconds = this.datePartDiff(prevDate.getSeconds(), currDate.getSeconds(), 60); * * this.minutes = this.datePartDiff(prevDate.getMinutes(), currDate.getMinutes(), 60); * * this.hours = this.datePartDiff(prevDate.getHours(), currDate.getHours(), 24); * * this.days = this.datePartDiff(prevDate.getDate(), currDate.getDate(), this.numOfDays[currDate.getMonth()]); * * this.months = this.datePartDiff(prevDate.getMonth(), currDate.getMonth(), 12); * * this.years = this.datePartDiff(prevDate.getFullYear(), currDate.getFullYear(),0); } * CountUp.prototype.addLeadingZero=function(value){ * * return value < 10 ? ("0" + value) : value; } * CountUp.prototype.formatTime=function(){ * * this.seconds = this.addLeadingZero(this.seconds); * * this.minutes = this.addLeadingZero(this.minutes); * * this.hours = this.addLeadingZero(this.hours); } * CountUp.prototype.updateCounter=function(){ * * this.calculate(); * * this.formatTime(); * * this.countainer.innerHTML ="<strong>" + this.years + "</strong> <small>" + (this.years == 1? "year" : "years") + "</small>" + * * * * " <strong>" + this.months + "</strong> <small>" + (this.months == 1? "month" : "months") + "</small>" + * * * * " <strong>" + this.days + "</strong> <small>" + (this.days == 1? "day" : "days") + "</small>" + * * * * " <strong>" + this.hours + "</strong> <small>" + (this.hours == 1? "hour" : "hours") + "</small>" + * * * * " <strong>" + this.minutes + "</strong> <small>" + (this.minutes == 1? "minute" : "minutes") + "</small>" + * * * * " <strong>" + this.seconds + "</strong> <small>" + (this.seconds == 1? "second" : "seconds") + "</small>"; * * var self = this; * * setTimeout(function(){self.updateCounter();}, 1000); } * window.onload=function(){ new CountUp('January 27, 2012 03:26:00', 'counter'); } * </script> </head> How can to obtain length of string variable, for example if I have: var msg = 'hello world!'; Does it exist a method to count string characters? I've reading this forum for some time now and this is my first post. I hope to find an helpfull community here and to be able to help other users myself. I'm new to JS so this might be an simple question: I have an form that can be filled bij an user, some fields are calculated by Javascript. I need an code to be able to calculate 'live' the totals of the fields in the loop, that fields are the grey fields at the borro. This is (part of) my form: PHP Code: <table align="center" class="bd" border="0" cellspacing="1" cellpadding="2" width="500"> <tr> <td>Bewerking</td> <td>Prijs per uur</td> <td>Aantal uur</td> <td align="center">Totaal</td> <td>Opmerkingen</td> </tr> <?php for ($i=0; $i<=$bew_aantal_regels_corr; $i++) { ?> <tr> <td><?php if($error_bew_vergeten[$i] == "ja"){ $error_omschr = $error_omschr_bew_vergeten[$i]; include('includes/input_error.php'); } ?> <select name="bewerking[]" onChange="bew_uren(this, <?php echo $i ?>),bew_uren_tot(this, <?php echo $i ?>)"> <option></option> <?php $sql_bewerking = "SELECT omschrijving, tarief from sp_calc_werkzaamheden ORDER BY omschrijving ASC"; $res_bewerking = mysql_query($sql_bewerking,$con); while ($row_bewerking = mysql_fetch_assoc($res_bewerking)){ ?> <option <?php if($row_bewerking["omschrijving"] == $bew_omschr[$i]){ echo 'selected="selected"'; } ?> value=<?php echo $row_bewerking["tarief"] ?>><?php echo $row_bewerking["omschrijving"] ?></option> <?php } ?></select> <input type="hidden" name="bew_omschr[]" value="<?php if($bew_omschr[$i] != ''){ echo $bew_omschr[$i]; } ?>" /> </td> <td><input type="text" name="bew_tarief[]" onKeyup="bew_uren_tot(this, <?php echo $i ?>)" size="5" style="text-align:right" value="<?php if($bew_tarief[$i] != ''){ echo $bew_tarief[$i]; } ?>" /><?php if($error_bew_tarief[$i] == "ja"){ $error_omschr = $error_omschr_bew_tarief[$i]; include('includes/input_error.php'); } ?></td> <td><input type="text" name="bew_uren[]" onKeyup="bew_uren_tot(this, <?php echo $i ?>)" size="5" style="text-align:right" value="<?php if($bew_uren[$i] != ''){ echo $bew_uren[$i]; } ?>" /><?php if($error_bew_uren[$i] == "ja"){ $error_omschr = $error_omschr_bew_uren[$i]; include('includes/input_error.php'); } ?></td> <td><input type="text" name="bew_totaal[]" size="10" style="text-align:right;background-color: #f1f1f1" value="<?php if($bew_totaal[$i] != ''){ echo $bew_totaal[$i]; } ?>" readonly="readonly" /></td> <td><input type="text" name="bew_opmerkingen[]" size="75" value="<?php if($bew_opmerkingen[$i] != ''){ echo $bew_opmerkingen[$i]; } ?>" /></td> <td><input type="hidden" name="bew_id[]" value="<?php if($bew_id[$i] != ''){ echo $bew_id[$i]; } ?>" /></td> </tr> <?php } ?> <tr> <td>Regels: <input type="text" name="bew_regels" value="<?php if($bew_aantal_regels != ''){ echo $bew_aantal_regels; } ?>" size="3" /><?php if($error_bew_aantal_regels == "ja"){ $error_omschr = $error_omschr_bew_aantal_regels; include('includes/input_error.php'); } ?> <input type="hidden" name="bew_aantal_regels_oud" value="<?php if($bew_aantal_regels_oud != ''){ echo $bew_aantal_regels_oud; } ?>" size="3" /> <input type="hidden" name="bew_aantal_regels_db" value="<?php if($bew_aantal_regels_db != ''){ echo $bew_aantal_regels_db; } ?>" size="3" /></td> <td></td> <td><input type="text" name="bewerking_tot_uur" size="5" style="text-align:right;background-color: #f1f1f1"" value="<?php if($bewerking_tot != ''){ echo $bewerking_tot; } ?>" readonly="readonly" /></td> <td><input type="text"name="bewerking_tot" size="10" style="text-align:right;background-color: #f1f1f1"" value="<?php if($bewerking_tot_uur != ''){ echo $bewerking_tot_uur; } ?>" readonly="readonly" /></td> </tr> </table> I have a script that almost does what I need: a simple counter that counts inmigrants remmittences to their home countries. Counting starts at 150,000,000,000 and it increments by 35,000 every one minute. The following scripts does the job done but it does not record in a continious manner, it resets each time the page is visited: Here is the code: ( I hope I get some help to make it: no reseting in each page visit) -------------------------------------------------- <html> <head> <script language="javascript" type="text/javascript"> <!-- var startCount = 150000000000; var addPerMin = 35000; function ProcessCounter() { document.getElementById('cnt').innerHTML = addCommas(String(cnt++)); setTimeout('ProcessCounter()', SetTimeOutPeriod); } function PutSpan() { document.write('<span id="cnt"></span>'); } function addCommas(nStr) { var rgx = /(\d+)(\d{3})/; while (rgx.test(nStr)) { nStr = nStr.replace(rgx, '$1' + ',' + '$2'); } return nStr; } var cnt = startCount; var SetTimeOutPeriod = Math.floor((1000 * 60) / addPerMin); function displayCounter() { PutSpan(); ProcessCounter(); } //--> </script> </head> <body <font size="30"> <script language="javascript" type="text/javascript">javascript:displayCounter();</script> </font> </body> |