JavaScript - New To Javascript Time Counter !! Need A Guideline.
Hi,
I am trying to build a counter in javascript. The time on the counter should be displayed in hours, minutes and seconds<24:00:00>. When the counter reaches 00:00:00, it should stop.I read some books and they say that I must use the setInterval function to implement the timer. The problem is I don't know how to begin it. Could anybody give me some guidance on where to begin to do something like this. My javascript skills are basic as you can probably tell but I do like to learn it step by step. Thanks in advance Similar TutorialsHi, I have added a time counter in below code. This is used to track the total time of a project. If a person is going on break, then they will apply the break that stops the time counter. However, once they come back from break and end the break, then time is counting at double speed (two seconds instead at one second). Is there any mistake that I done that made the time counter to increment by 2 seconds instead of 1 second after break. Any help please.... Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <title>Strategy One - Tracker</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> <!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]--> <!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]--> <!-- Script for Current time in text box --> <script type="text/javascript"> function GetDate() { var curDateTime = new Date() var curHour = curDateTime.getHours() var curMin = curDateTime.getMinutes() if(curHour<10) curHour = "0" + curHour if(curMin<10) curMin = "0" + curMin document.getElementById('start_time').value = curHour + ":" + curMin; var row = document.getElementById("end1_time"); var row1 = document.getElementById("start1_time"); row.style.display = 'none'; row1.style.display = 'none'; } </script> <!-- End of Script for Current time in text box --> <!-- Script for Current time in text box --> <script type="text/javascript"> function GetDate1() { var curDateTime = new Date() var curHour = curDateTime.getHours() var curMin = curDateTime.getMinutes() if(curHour<10) curHour = "0" + curHour if(curMin<10) curMin = "0" + curMin document.getElementById('end_time').value = curHour + ":" + curMin; var row = document.getElementById("start1_time"); var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); var row3 = document.getElementById("end2_time"); row.style.display = 'none'; row1.style.display = 'none'; row2.style.display = 'none'; row3.style.display = 'none'; } </script> <script type="text/javascript"> function GetDate2() { var curDateTime = new Date() var curHour = curDateTime.getHours() var curMin = curDateTime.getMinutes() if(curHour<10) curHour = "0" + curHour if(curMin<10) curMin = "0" + curMin document.getElementById('break_time_out').value = curHour + ":" + curMin ; var row = document.getElementById("end2_time"); row.style.display = ''; } </script> <script type="text/javascript"> function GetDate3() { var curDateTime = new Date() var curHour = curDateTime.getHours() var curMin = curDateTime.getMinutes() if(curHour<10) curHour = "0" + curHour if(curMin<10) curMin = "0" + curMin document.getElementById('break_time_in').value = curHour + ":" + curMin ; } </script> <script type="text/javascript"> function tout1() { var temp= document.tracker.start_time.value; if(temp.length>0) { var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); row1.style.display = 'none'; row2.style.display = 'none'; } else { var row = document.getElementById("start1_time"); var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); row.style.display = 'none'; row1.style.display = 'none'; row2.style.display = 'none'; } } function tout2() { var temp= document.tracker.start_time.value; if(temp.length>0) { var row = document.getElementById("start1_time"); var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); var row3 = document.getElementById("end2_time"); row.style.display = 'none'; row1.style.display = 'none'; row2.style.display = 'none'; row3.style.display = 'none'; } else { var row = document.getElementById("start1_time"); var row1 = document.getElementById("end1_time"); var row2 = document.getElementById("start2_time"); var row3 = document.getElementById("end2_time"); row.style.display = ''; row1.style.display = 'none'; row2.style.display = 'none'; row3.style.display = 'none'; } } </script> <script type="text/javascript"> var seconds = 0; var minutes = 0; var hours = 0; function zeroPad(time) { var numZeropad = time + ''; while(numZeropad.length < 2) { numZeropad = "0" + numZeropad; } return numZeropad; } function countSecs() { var j=document.tracker.hide.value; if(j=="yes") { seconds++; if (seconds > 59) { minutes++; seconds = 0; } if (minutes > 59) { hours++ minutes = 0; } document.tracker.time_utilization.value = zeroPad(hours) + ":" + zeroPad(minutes) + ":" + zeroPad(seconds); } else {} } function startTimer() { action = window.setInterval(countSecs,1000); } function s() { document.tracker.hide.value ="yes"; startTimer(); } function p() { document.tracker.hide.value ="no"; } </script> </head> <body> <form name="tracker" method="post" action="processor.php" onsubmit="return formCheck(this);"> <label class="formFieldQuestion">Start Time *</label><input readonly class=mainForm type=text name=start_time id=start_time size='30' value=''> <input type="button" id="start1_time" style="width: 100px" Value="Start Time" onClick="javascript:GetDate();s();"></li> <label class="formFieldQuestion">End Time *</label><input readonly class=mainForm type=text name=end_time id=end_time size='30' value='' > <input type="button" id="end1_time" style="width: 100px" Value="End Time" onClick="javascript:GetDate1(); p();" style='display: none'></li> <input type="hidden" name="hide" /> <label class="formFieldQuestion">Break Time Out </label><input class=mainForm readonly type=text name=break_time_out id=break_time_out size='30' value='' > <input type="button" id="start2_time" style="width: 100px" Value="Start Time" onClick="javascript:GetDate2();tout1();p();"></li> <label class="formFieldQuestion">Break Time In </label><input class=mainForm readonly type=text name=break_time_in id=break_time_in size='30' value=''> <input type="button" id="end2_time" style="width: 100px" Value="End Time" onClick="javascript:GetDate3(); tout2();s();" style='display: none'></li> <label class="formFieldQuestion">Time Utilization</label><input class=mainForm type=text name=time_utilization id=time_utilization size='30' value='' readonly></li> <br /> <br /> <input id="saveForm" class="mainForm" type="submit" value="Submit" style="width : 100px"/> </form> </body> </html> I need to make a counter that counts up (preferably in real time but not crucial). Ideally, it would count up by 9 dollars per second and go to the hundred millions. Thanks in advance! One that I have seen is at www.costofwar.com This is in real time, but that feature is not crucial. Hey Everyone, I'm working on a counter. I have two images - each with their own click count. Right now each time the page loads the counter goes back to zero. I would assume I need some kind of server side coding. Any recommendations? Here's what I have so far. <html> <head> <script type="text/javascript"> var counter = 0; function increaseloveit() { counter += 1; document.getElementById('loveit').value = counter; } var counter = 0; function increasehateit() { counter += 1; document.getElementById('hateit').value = counter; } </script> </head> <body> <form> <a href="#" onclick="javascript:increaseloveit();"><input type="button" value="Love It!" name="loveit" onclick="" /></a><input id="loveit" value="0" size="2" /></form> <form> <a href="#" onclick="javascript:increasehateit();"><input type="button" value="Hate It!" name="hateit" onclick="" /></a><input id="hateit" value="0" size="2" /></form> </body> </html> I have the following code but it is not even showing up in the browser. I am very new to JS and very willing to learn. The code was originally found on this site and I have tweaked it and now it doesn't work...Any assistance would be much appreciated. <script type = "text/javascript"> var seconds; var clockId; function startClock(seconds){ timeInSeconds = parseInt(seconds); clockId = setInterval("tick()",1000); } function runClock() { var seconds = timeInSeconds; if (seconds > 60) { // stop at "" seconds alert ("Your time is up!"); clearInterval(clockId); // stop counting return false; } else { timeInSecs++; } var hours= Math.floor(seconds/3600); seconds %= 3600; var mins = Math.floor(seconds/60); secs %= 60; var result = ((hours < 10 ) ? "0" : "" ) + hours + ":" + ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secondss < 10) ? "0" : "" ) + seconds; document.getElementById("countdown").innerHTML = result; } startClock(0); // start count at 0 seconds </script> <span id="countdown" style="font-weight: bold;"></span> Hey Everyone, I'm trying to set up two different buttons that count their own individual clicks. So far I have everything except where one button leaves off, the other picks up. So if I click the left one three times it shows the number 3, and then if I click the button next to it, that button picks up at 4. I want each button to have its own count. Any ideas? Here's what I have so far. <html> <head> <script type="text/javascript"> var counter = 0; function increaseloveit() { counter += 1; document.getElementById('loveit').value = counter; } var counter = 0; function increasehateit() { counter += 1; document.getElementById('hateit').value = counter; } </script> </head> <body> <form> <a href="#" onclick="javascript:increaseloveit();"><input type="button" value="Love It!" name="loveit" onclick="" /></a><input id="loveit" value="0" size="2" /></form> <form> <a href="#" onclick="javascript:increasehateit();"><input type="button" value="Hate It!" name="hateit" onclick="" /></a><input id="hateit" value="0" size="2" /></form> </body> </html> 1 down vote favorite I do have the countdown script (see link below) to display the time between current time and the date given in real-time. However, I want to achieve to display the time difference between a given start and end time. Right now, it calculates from the current server time to the end time. I want to be able to set up my own start time and end time. Here is what I have: http://jsfiddle.net/BgEtE/ thank you for help I am using the counter script below to display a count from 1-36. Does anyone know how to edit the javascript to flash or blink the number 36 a few times, and then loop the script to start over and count from 1-36 again (and again)? Here's the script: <html> <head> <title></title> </head> <script type="text/javascript"> var t, max, i; function Increase(amount) { max = amount; i = parseInt(document.getElementById("count").value); t = setInterval("SetIncrease()", 500); } function SetIncrease() { document.getElementById("count").value = ++i; if(i == max) { clearTimeout(t); } } </script> <body onLoad="Increase(36);"> <input id="count" type="text" value="1" style="width:40px;font-family:georgia;font-size:30px;font-weight:bold;color:#CC0000;border: 0px solid #000000;text-align:right;background-color:#FFFF00;" align="center"> </body> </html> Many thanks! hello, I have a textbox in my .net page, and totally new to java script. How do i get a script that will count the data being written in the text box to show increments of 100 and write the value to the bottom of the textbox. e.g. When u get to 100, at the bottom it says "1st hundred" ... and to 200 it writes "2nd hundred" UP to 500 ??? Please help thanks Hello, I actually use a counter on a webpage (It works) To do it, I use an inline javascript but I would like to unify the entire page and call that counter directly in the external Javascript that manages the whole site. Here's the actual code... Code: HTML <body onLoad=gen_hits()> ... <span id='hits'></span><SCRIPT language="JavaScript" SRC="http://www.mycompany.com/cgi-bin/counterdir/gcount.pl?NUMBER=../../otherdir/counter"></SCRIPT> ... </body> EXTERNAL JAVASCRIPT (ini.js) var hits="HITS "; function gen_hits() { document.getElementById("hits").innerHTML=hits; } and here a "view" of my request... Code: HTML <body onLoad=gen_hits()> ... <span id='hits'></span> ... </body> EXTERNAL JAVASCRIPT var hits="HITS " + <SCRIPT language="JavaScript" SRC="http://www.mycompany.com/cgi-bin/counterdir/gcount.pl?NUMBER=../../otherdir/counter"> </SCRIPT> ; function gen_hits() { document.getElementById("hits").innerHTML=hits; } Any idea how to modify it ? Thank you very much Gino I want to make a javascript clock (using Server time and not user computer time). After searching I have found the code on http://www.elated.com/articles/creat...ascript-clock/ The Code is: PHP 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> <style type="text/css"> #clock { font-family: Arial, Helvetica, sans-serif; font-size: 0.8em; color: white; background-color: black; border: 2px solid purple; padding: 4px; } </style> <script type="text/javascript"> <!-- function init ( ) { timeDisplay = document.createTextNode ( "" ); document.getElementById("clock").appendChild ( timeDisplay ); } function updateClock ( ) { var currentTime = new Date ( ); var currentHours = currentTime.getHours ( ); var currentMinutes = currentTime.getMinutes ( ); var currentSeconds = currentTime.getSeconds ( ); // Pad the minutes and seconds with leading zeros, if required currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes; currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds; // Choose either "AM" or "PM" as appropriate var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM"; // Convert the hours component to 12-hour format if needed currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours; // Convert an hours component of "0" to "12" currentHours = ( currentHours == 0 ) ? 12 : currentHours; // Compose the string for display var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay; // Update the time display document.getElementById("clock").firstChild.nodeValue = currentTimeString; } // --> </script> </head> <body onload="updateClock(); setInterval('updateClock()', 1000 )"> <div> <span id="clock"> </span> </div> </body> </html> The problem is that it (the code above) is using the users computer time. (I found (in the comments of http://www.elated.com/articles/creat...ascript-clock/) that I should use: PHP Code: var currentTime = [serverValue goes here]; But I don't really know what should I put in the "serverValue goes here" ..... ) So how can I make this code to use the server time (and not the users time)? Any Suggestion Will Be Helpfull Hi I hope I hit the topic I have a problem in java script i need it for an online game that I develop but not as I do not go javasript countdown or can help me I need a timer that counts down and ceases to move to the other side but not when Refresh to go back and allow you to set time thanks in advance
Hi, I'm not too familiar with javascript but I am trying to find a script which I can enter a specific time and date and when that date is reached the script will alert me with a desired message. (not looking for a calendar) Help would be appreciated Harry I cannot get my JavaScript code to work. Does anyone know what I am doing wrong with the following code: <html> <head> <title>Welcome</title> </head> <body> <h1>Welcome to my Web Page</h1> <script type="text/javascript"> /* <![CDATA[ */ var dateObject = new Date(); var greeting = ""; var curTime = ""; var minuteValue = dateObject.getMinutes(); var hourValue = dateObject.getHours(); if (minuteValue < 10) minuteValue = "0" + minuteValue; if(hourValue < 12) { greeting = "<p>Good morning! " curTime = hourValue + ":" + minuteValue + " AM"; } else if (hourValue == 12) { greeting = "<p>Good afternoon! "; + minute Value + " PM"; } else if (hourValue == 17) { greeting = "<p>Good afternoon!" cutTime = (hourValue-12) + ":" + minuteValue + " PM" } else { greeting = "<p>Good evening! " curTime = (hourValue-12) + ":" + minuteValue + " PM" } var dayArray = newArray("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); var monthArray = newArray("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var day = dateObject.getDay(); var month = dateObject.getMonth(); document.write("<p>"+ greeting + "It is " + curTime + " on " + dayArray[day] + ", " + monthArray[month] + " " + dateObject.getDate() + ", " + dateObject.getFullYear() + ".</p>"); /* ]]> */ </script> </body> </html> ~xhtml205 Hello, I was given an assignment to change an existing form into one that will automatically perform calculations and since I have never done this before I am learning as I go. The form needs to do the following: gr_percentage = list_percentage + sale_percentage gr_comm_dollars = gr_percentage * price list_comm_dollars = list_percentage * price and so on. I also need to calculate the following gr_total_dollars = gr_comm_dollars + gr_fixed_dollars + gr_bonus_dollars (all of which will be calculated on entries for the sale and list portions). I though that I had it figured out but upon testing the form it does nothing. Please let me know what I need to change in order for the calculations to work properly. Thank you Code: <script type="text/javascript"> function calculate(Id) { var price = document.getElementById('price').value; var REO_list_percentage = document.getElementById('REO_list.percentage').value; var REO_sale_percentage = document.getElementById('REO_sale_percentage').value; var REO_sale_dollars = document.getElementById('REO_sale_dollars').value var REO_list_dollars = document.getElementById('REO_list_dollars').value var REO_sale_bonus_dollars = document.getElementById('REO_sale_bonus_dollars').value; var REO_list_bonus_dollars = document.getElementById('REO_list_bonus_dollars').value; var REO_sale_fixed_dollars = document.getElementById('REO_sale_fixed_dollars').value; var REO_list_fixed_dollars = document.getElementById('REO_list_fixed_dollars').value; var gr_comm_dollars = document.getElementById('gr_comm_dollars').value; var gr_bonus_dollars = document.getElementById('gr_bonus_dollars').value; var gr_fixed_dollars = document.getElementById('gr_fixed_dollars').value; document.getElementById('gr_comm_percentage').value=REO_list_percentage + REO_sale_percentage; document.getElementById('gr_comm_dollars').value=gr_comm_percentage/100*price; document.getElementById('reo_list_dollars').value=REO_list_percentage/100*price; document.getElementById('reo_sale_dollars').value=REO_sale_percentage/100*price; document.getElementById('gr_fixed_dollars').value=REO_sale_fixed_dollars + REO_list_fixed_dollars; document.getElementById('gr_bonus_dollars').value=REO_sale_bonus_dollars + REO_list_bonus_dollars; document.getElementById('gr_total_dollars').value=gr_comm_dollars + gr_fixed_dollars + gr_bonus_dollars; document.getElementById('REO_sale_total_dollars').value = REO_sale_comm_dollars + REO_sale_fixed_dollars + reo_sale_bonus_dollars; document.getElementById('REO_list_total_dollars').value = REO_list_comm_dollars + REO_list_fixed_dollars + reo_list_bonus_dollars; gr_comm_dollars = isNAN(gr_comm_dollars)?0:parseFloat(gr_comm_dollars,10); gr_fixed_dollars = isNAN(gr_fixed_dollars)?0:parseFloat(gr_fixed_dollars,10); gr_bonus_dollars = isNAN(gr_bonus_dollars)?0:parseFloat(gr_bonus_dollars,10); } </script> </head> //here is the form <tr > <td><cfoutput><cfif #form.list_type# IS 1 OR #form.list_type# IS 2><b>*</b></cfif></cfoutput><b>Sold Price</b> </td> <td><input type="text" id="price" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate('gr_comm_dollars','REO_sale_dollars','REO_list_dollars')" /></td> </tr> <tr><td colspan="2"><b>Commission Information</b> </td> </tr> <!---Form headings---> <tr><td> </td> <td colspan="2" align="center"><b>Main Commission</b></td> <td align="center"><b>Fixed</b></td> <td align="center"><b>Bonus/<br />Other</b></td> <td align="center"><b>Total</b></td> </tr> <tr> <td> </td> <td><b>%</b></td> <td><b>$</b></td> <td><b>$</b></td> <td><b>$</b></td> <td><b>$</b></td> </tr> <!---End form headings---> <tr><td><b>*</b>Gross Comm</td> <td><input type="Text" id="gr_comm_percentage" size="1" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'"onchange="calculate ('gr_comm_dollars')" > </td> <td><input type="text" id="gr_comm_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate('gr_total_dollars')"> </td> <td><input type="text" id="gr_fixed_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'"onchange="calculate ('gr_total_dollars')"> </td> <td><input type="text" id="gr_bonus_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'"onchange="calculate('gr_total_dollars')"> </td> <td><input type="text" name="gr_total_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'"> </td> </tr> <tr> <cfoutput> <cfif #form.list_type# IS 2> <td><b>*</b>REO List </td><!---Comp. Dollar---> <td><input type="Text" id="REO_list_percentage" size="1" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate('gr_commission_percentage','REO_list_dollars')"> </td> <td><input type="text" id="REO_list_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate ('REO_list_total_dollars')"> </td> <td><input type="text" id="REO_list_fixed_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate ('REO_list_total_dollars')"> </td> <td><input type="text" id="REO_list_bonus_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate ('REO_list_total_dollars')"> </td> <td><input type="text" id="REO_list_total_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'"> </td> <!---List type 1 begins here---> <cfelseif #form.list_type# IS 1 ><td><b>*</b>Amt Pd to O/B</td> <td><input type="Text" name="OB_percentage" size="1" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'">% </td> <td>$<input type="text" name="OB_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" > </td> <cfelse><td>Amt Pd to O/B</td> <td><input type="Text" name="OB_percentage" size="1" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'">% </td> <td>$<input type="text" name="OB_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'"> </td> </cfif> </cfoutput> </tr> <tr> <cfoutput> <cfif #form.list_type# IS 2> <td><b>*</b>REO Sale </td><!---Comp. Dollar---> <td><input type="Text" id="REO_sale_percentage" size="1" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate('gr_commission_percentage','REO_sale_dollars')"> </td> <td><input type="text" id="REO_sale_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate ('REO_sale_total_dollars')" > </td> <td><input type="text" id="REO_sale_fixed_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate ('REO_sale_total_dollars')"> </td> <td><input type="text" id="REO_sale_bonus_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'" onchange="calculate ('REO_sale_total_dollars')"> </td> <td><input type="text" id="REO_sale_total_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'"> </td> <cfelse><td><b>*</b>REO Gross</td> <td><input type="Text" name="comp_percentage" size="1" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'">% </td> <td>$<input type="text" name="comp_dollars" size="8" class="TextBox" onfocus="this.className='TextBoxSelected';select()" onblur="this.className='TextBox'"> </td> </cfif> </cfoutput> </tr> <tr> Hello everyone! I hope you can help me. I am writing a submit form that has to have an indication if a form is information is missing. I have followed along the steps with my text and I can't seem to figure out what I am doing wrong. Can anyone help me? Here is my code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD.HTML 4.01 Transitional//EN" "http://www.w3.org/TR/htm14/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Kudler Fine Foods Contact Page</title> <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"> <!---Kami Demnyan 21 December 2009--> <script type="text/javascript"> /*<![CDATA[*/ <!--This code ensures that the zip code and telephone numbers are actual numerical digits, not letters--> function checkForNumber(fieldValue) { var numberCheck = isNaN(fieldValue); if (numberCheck == true) { window.alert ("Please enter a numerical value"); return false; } } <!--This code ensures that all of the fields contain text, its not functioning, I'm using page 263 in the text as my guide--> function submitForm() { if (document.forms[0].name.value == "" || document.forms[0].address.value == "" || document.forms[0].city.value == "" || document.forms[0].state.value == "" || document.forms[0].zip.value == "" || document.forms[0].phone.value == "" || document.forms[0].email.value == "") { window.alert("Please enter your missing information"); return false; } else return true; } /*]]>*/ </script> </head> <body> <h1> KUDLER FINE FOODS </h1> <h2> JOIN OUR MAILING LIST</h2> <!--This is where the user will input all of their information to join the mailing list--> <form action="completeform.html" method="get" onsubmit="return onSubnit();" enctype="application/x-www-form-urlencoded"> <p>Name<br /> <input type="text" name="name" size="50" /></p> <p>Address<br /> <input type="text" name="address" size="50" /></p> <p>City, State, Zip <br /> <input type="text" name="city" size="30" /> <input type="text" name="state" size="3" /> <input type="text" name="zip" size="10"; onchange="return checkForNumber(this.value)"; /></p> <p>Telephone<br /> <input type="text" name="phone" size="25" onchange="return checkForNumber(this.value)"; /></p> <p>Email Address<br /> <input type="text" name="email" size="50" /></p> <!--This is where the submit and reset buttons are located--> <p><input type="submit" value="Submit Form" /> <p><input type="reset" value="Reset Form" /> </form> </body> </html> ALSO: My instructor does not want me to use the onchange tag, is there a suitable replacement for that? Any help would be greatly appreciated, thank you. Kami I have this code on my invisionfree forum that is suppose to change a layout from 6 AM - 6 PM but it isn't working. Here is the code Code: <script language="javascript"> /* script created by Chandler @ http://s4.invisionfree.com/digitalized <-- a great site for skins codes and support! */ now = new Date(); itime = now.getHours(); function TSkinChange() { if (itime >= 19) { document.write('<LINK REL="stylesheet" TYPE="text/css" HREF="http://hatchingyourdragons.com/daynocturne.css">'); } if (itime <= 6) { document.write('<LINK REL="stylesheet" TYPE="text/css" HREF="http://hatchingyourdragons.com/nightnocturne.css">'); }} TSkinChange(); </script> Thanks in advance Hi All, i want to achieve an effect like the following, please help 1. i want to get the current time, possibility no from client computer ( sometimes their time is wrong)? i dont know whether can achieve but if cannot, then never mind, just get from client computer. 2. for example now is 1:25 am, i want to generate dynamically every half an hour timing from 2 am(round up) till for example 11 am something like <select> <option>2:00</option> <option>2:30</option> ................ <option>11:00</option> </select> for me this is a bit complicated, anybody can help me? <option>3:00</option> I am trying to set up a web that new times will be displayed when they add current times to a form. here is the static HTML <form method="POST" > current time is 11:32 AM</p> <p>add <input type="text" name="T1" size="5" value="20"> mins and the new time time would be <b> 11:52 AM</b></p> <p>add another<input type="text" name="T2" size="5" value="15"> mins and the time then changes to <b>12:07 PM</b></p> <p><input type="submit" value="Submit" name="B1"></p> <p><input type="reset" value="Reset" name="B2"></p> </form> I would like to have the new times to change dynamically as they type in either (or both) input boxes Hey all, I have a couple of videos that display on web page. I want one to display 5 seconds after another when someone clicks a link. Now I know of the setTimeout method, but I can't seem to get it to work in this below code. The thing is both of the video elements are in the same function. Any help will be greatly appreciated: Code: <script type="text/javascript"> <!-- window.onload = initLinks; var myVid = new Array("area2d.swf","Bar2D.swf", "Column3D.swf", "Column2D.swf"); var myFlash = new Array("data/Area2D.xml","data/Bar2D.xml", "data/Column3D.xml", "data/Column2D.xml"); var thisVid = 0; function initLinks() { document.getElementById("vid1").onclick = processVid1; document.getElementById("vid2").onclick = processVid2; document.getElementById("vid3").onclick = processVid3; document.getElementById("prevLink").onclick = processPrevious; document.getElementById("nextLink").onclick = processNext; } function processVid1() { document.getElementById("myVideo").src = myVid[0]; document.getElementById("myVideo").dataURL = myFlash[0]; document.getElementById("myVideo2").src = myVid[1]; document.getElementById("myVideo2").dataURL = myFlash[1]; return false } function processVid2() { document.getElementById("myVideo").src = myVid[2]; document.getElementById("myVideo").dataURL = myFlash[2]; document.getElementById("myVideo2").src = myVid[3]; document.getElementById("myVideo2").dataURL = myFlash[3]; return false } function processVid3() { document.getElementById("myVideo").src = myVid[2]; return false } function processPrevious() { if (thisVid == 0) { thisVid = myVid.length; } thisVid--; document.getElementById("myVideo").src = myVid[thisVid]; return false; } function processNext() { thisVid++; if (thisVid == myVid.length) { thisVid = 0; } document.getElementById("myVideo").src = myVid[thisVid]; return false; } --> </script> </head> <body> <div id="slideshow"> <h1>Introducing</h1> <table width=""> <tr> <td> <embed src="area2d.swf" flashVars="&dataURL=data/Area2D.xml&debugMode=0&chartWidth=295&chartHeight=295" quality="high" width="295" height="295" type="application/x-shockwave-flash" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" id="myVideo" /> </embed> <td <td> <embed src="Bar2D.swf" flashVars="&dataURL=data/Bar2D.xml&debugMode=0&chartWidth=295&chartHeight=295" quality="high" width="295" height="295" type="application/x-shockwave-flash" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" id="myVideo2" /> </embed> <td </tr> </table> </div> <div id="pageTree"> <ul> <li><a href="video1.html" id="vid1">Area</a></li> <li><a href="video2.html" id="vid2">Bar</a></li> <li><a href="video3.html" id="vid3">Inventory</a></li> </ul> </div> <div align="center"> <h2><a href="previous.html" id="prevLink">« Previous</a> <a href="next.html" id="nextLink">Next »</a></h2> </div> </body> http://whitelemondesigns.com/test/about.html I can't for the life of me figure out where I'm going wrong with the scroll bar... I think I've got all the html and css correct, I have to assume there's a javascript error but I can't find it... could I have a javascript conflict? If you guys have any insight I would appreciate it, this is driving me up a wall. |