JavaScript - Javascript Incorrectly Displays Time Left
Hi, I need your help with a javascript that is incorrectly displaying the time left as 12 hours instead of 24 hours.
The target date is July 7, 2010 at 09:00 AM Here is the url where the script is installed: http://guaranteedtransformation.com/independence/ and here is the code: Code: <script LANGUAGE="JavaScript"> // This following statement must be left intact. // Copyright (c) Michael Bloch and Taming The Beast. // Countdown timer script v1.2 April 20 2009 // Taming the Beast.net - http://www.tamingthebeast.net // Free Web Marketing and Ecommerce articles and tools // By using this code you agree to indemnify Taming the Beast // from from any liability that might arise from its use. // The preceding statement be left intact. var present; var future; var tseconds; var seconds; var minutes; var hours; var days; ID=setTimeout("countdown();", 1000); function countdown() { present = new Date(); present = present.getTime() + (60000) + (12 * 60 * 60 * 1000); future = new Date("July 07, 2010 09:00:00"); tseconds = (future - present) / 1000; days = tseconds /24/60/60; days = Math.floor(days); tseconds = tseconds - (days * 24 * 60 * 60); hours = tseconds /60/60; hours = Math.floor(hours); tseconds = tseconds - (hours * 60 * 60); minutes = tseconds /60; minutes = Math.floor(minutes); tseconds = tseconds - (minutes * 60); seconds = tseconds; seconds = Math.floor(seconds); document.getElementById('days').innerHTML = days; document.getElementById('hours').innerHTML = hours; document.getElementById('minutes').innerHTML = minutes; document.getElementById('seconds').innerHTML = seconds; ID=setTimeout("countdown();", 1000); } </script> And here is the html that displays the time: Code: <SPAN id="days">0</SPAN> days, <SPAN id="hours">0</SPAN> hours, <SPAN id="minutes">0</SPAN> minutes, <SPAN id="seconds">0</SPAN> seconds Thanks for your help, Jimmy Similar Tutorials1 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 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 I am working with using Javascript to create a page that scales and keeps its aspect ratio (much like a Flash page would). After a lot of trial and error, I have a prototype up with a couple of problems. It loads correctly once in I.E. Reloading, or opening a new browser, will also load the page correctly. But visiting a different page and coming back causes the width attributes to break. This happens with the non-aspect-ratio version in pure HTML also, but I was hoping that this problem would be solved by establishing values based on javascript variables. As for Firefox, the problem is more or less exactly the opposite. The page loads up all wonky the first time, and a reload or resize will fix it for every time afterward. To see what I'm talking about, you can take a look at http://www.jonesmfgmusic.com/testpag...lem_width.html For the HTML only version, see http://www.jonesmfgmusic.com/testpag...blem_html.html I'm guessing this is something to do with the order in which the data is loaded, so that once the information is all cached, it stops functioning in IE, and starts functioning in FF... can anyone confirm whether I'm on the right track with that, or how to fix it if I am? I'm most concerned by the fact that the width attribute is behaving as it does in IE. That looks like some kind of Microsoft bug to me, and I need a way around it. As for Firefox, I am guessing if I can just get it to load all of the correct information ahead of time, the page should come up correctly, but I just can't think how to do that. 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> 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 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 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 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> 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 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 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> Hi all. Can someone please help me make this code accurate so it counts the correct number of characters? when u click on the box, it should display 0. when u type in the box, it should count up by 1. when u click on the box, and u delete a character or characters, it subtracts that many code: Code: <form method="POST"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100%"> <textarea onkeyDown="count_it(this)" rows="12" name="charcount" cols="60" wrap="virtual"></textarea> </td> </tr> <tr> <td width="100%"><div align="right"><p> <input type="text" name="displaycount" size="20"></p> </div></td> </tr> </table> </form> <script language="JavaScript"> function count_it(what){ formcontent=what.form.charcount.value what.form.displaycount.value=formcontent.length } </script> hi i am using jquery for ajax request response. Is there any javascript functions which can cause some time delay like Code: ajaxStart(function() { showAnimation(); delay(5000s): }); When I click the button to open an url (example: http://www.yahoo.com) from a page, I can mark this url/screen name. So the next time I click on the same button, the same window will pop up instead of opening multiple windows. If I have already had the window opened not via the button, when clicking the button, it pops up a new window instead of opening up the existing. Is there a way to check the screen name or partial url of the existing window? If there is a match with the url being called from the button, it will use the existing one. 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 Hi guys. I'm trying to make a small bit of scripting that will show the current time, updating once every second. What I need is the following: 1. Multiple timezones or GMT offsets (just put me on the right path, I can code them in, 2. Daylight savings time taken into consideration (only for Australia), adding the 1 hour during the times it is needed, 3. Text to show "Open" and "Closed" during different times (open during 8am to 5pm and closed if not 8am to 5pm.) I have the following code as a start, but I am completely stuck with how to get the rest of what I need! Any help would be appreciated. <h4>Victoria <script type="text/javascript"> <!-- var currentTime = new Date() var hours = currentTime.getHours() var minutes = currentTime.getMinutes() if (minutes < 10){ minutes = "0" + minutes } document.write(hours + ":" + minutes + " ") if(hours > 11){ document.write("PM") } else { document.write("AM") } //--> </script> <script type="text/javascript"> <!-- var currentTime = new Date() var hours = currentTime.getHours() var minutes = currentTime.getMinutes() if (minutes < 10){ minutes = "0" + minutes } if(hours > 11){ document.write("True") } else { document.write("False") } //--> </script> </h4> Cheers in advance. Dale. Can anyone help? i'm trying to find some references and resources on how to hide a link at a certain time and show the link again at a certain time. eg: from 12pm to 2pm the link will be display, users are able to click the link. after 2pm the link will not be displayed[hide] or the when click on the link error message will be shown. plz help. thanks! I downloaded a popup datepicker from javascriptkit.com. All great but can't take the time out of the footer. I only want the date to show, and once selected, I would like the field to be filled with "Day, Date, Month, Year" (no time). Code is as follows: Code: function show_calendar(str_target, str_datetime) { var arr_months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]; var n_weekstart = 1; // day week starts from (normally 0 or 1) var dt_datetime = (str_datetime == null || str_datetime =="" ? new Date() : str2dt(str_datetime)); var dt_prev_month = new Date(dt_datetime); dt_prev_month.setMonth(dt_datetime.getMonth()-1); var dt_next_month = new Date(dt_datetime); dt_next_month.setMonth(dt_datetime.getMonth()+1); var dt_firstday = new Date(dt_datetime); dt_firstday.setDate(1); dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7); var dt_lastday = new Date(dt_next_month); dt_lastday.setDate(0); // html generation (feel free to tune it for your particular application) // print calendar header var str_buffer = new String ( "<html>\n"+ "<head>\n"+ " <title>Calendar</title>\n"+ "</head>\n"+ "<body bgcolor=\"White\">\n"+ "<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+ "<tr><td bgcolor=\"#4682B4\">\n"+ "<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+ "<tr>\n <td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar('"+ str_target+"', '"+ dt2dtstr(dt_prev_month)+"'+document.cal.time.value);\">"+ "<img src=\"prev.gif\" width=\"16\" height=\"16\" border=\"0\""+ " alt=\"previous month\"></a></td>\n"+ " <td bgcolor=\"#4682B4\" colspan=\"5\">"+ "<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">" +arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+ " <td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('" +str_target+"', '"+dt2dtstr(dt_next_month)+"'+document.cal.time.value);\">"+ "<img src=\"next.gif\" width=\"16\" height=\"16\" border=\"0\""+ " alt=\"next month\"></a></td>\n</tr>\n" ); var dt_current_day = new Date(dt_firstday); // print weekdays titles str_buffer += "<tr>\n"; for (var n=0; n<7; n++) str_buffer += " <td bgcolor=\"#87CEFA\">"+ "<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+ week_days[(n_weekstart+n)%7]+"</font></td>\n"; // print calendar table str_buffer += "</tr>\n"; while (dt_current_day.getMonth() == dt_datetime.getMonth() || dt_current_day.getMonth() == dt_firstday.getMonth()) { // print row heder str_buffer += "<tr>\n"; for (var n_current_wday=0; n_current_wday<7; n_current_wday++) { if (dt_current_day.getDate() == dt_datetime.getDate() && dt_current_day.getMonth() == dt_datetime.getMonth()) // print current date str_buffer += " <td bgcolor=\"#FFB6C1\" align=\"right\">"; else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6) // weekend days str_buffer += " <td bgcolor=\"#DBEAF5\" align=\"right\">"; else // print working days of current month str_buffer += " <td bgcolor=\"white\" align=\"right\">"; if (dt_current_day.getMonth() == dt_datetime.getMonth()) // print days of current month str_buffer += "<a href=\"javascript:window.opener."+str_target+ ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+ "<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">"; else // print days of other months str_buffer += "<a href=\"javascript:window.opener."+str_target+ ".value='"+dt2dtstr(dt_current_day)+"'+document.cal.time.value; window.close();\">"+ "<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">"; str_buffer += dt_current_day.getDate()+"</font></a></td>\n"; dt_current_day.setDate(dt_current_day.getDate()+1); } // print row footer str_buffer += "</tr>\n"; } // print calendar footer str_buffer += "<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#87CEFA\">"+ "<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+ "Time: <input type=\"text\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+ "\" size=\"8\" maxlength=\"8\"></font></td></tr>\n</form>\n" + "</table>\n" + "</tr>\n</td>\n</table>\n" + "</body>\n" + "</html>\n"; var vWinCal = window.open("", "Calendar", "width=200,height=250,status=no,resizable=yes,top=200,left=200"); vWinCal.opener = self; var calc_doc = vWinCal.document; calc_doc.write (str_buffer); calc_doc.close(); } // datetime parsing and formatting routimes. modify them if you wish other datetime format function str2dt (str_datetime) { var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/; if (!re_date.exec(str_datetime)) return alert("Invalid Datetime format: "+ str_datetime); return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6)); } function dt2dtstr (dt_datetime) { return (new String ( dt_datetime.getDate()+"-"+(dt_datetime.getMonth()+1)+"-"+dt_datetime.getFullYear()+" ")); } function dt2tmstr (dt_datetime) { return (new String ( dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds())); } This is called with: Code: <html lang="en"> <head> <script language="JavaScript" src="ts_picker.js"> </script> </head> <body> <form name="tstest"> <input type="Text" name="timestamp" value=""> <a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);"><img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp"></a> </form> </body> </html> Thanks for any help!!! Ruth |