JavaScript - Taking Hours Out Of This Countdown
hi guys, as im still a noob at javascript, so im asking for your help, i didnt make this script, someone else did and i asked for their permission to change it to my needs, the problem is, i have it working for times that are over an hour long, but i need to also make it possible to display in just under an hour aswell, eg instead of 01:00:00 it would display 60:00 then 59:59 eg, so basically im asking, how can i take the hours out of this, without it currupting the entire JS?
Code: var HAS_EXPIRED = 'Time has Expired!'; var IS_NONE = 'None'; function secondCountdown(s){ if(s){ var timeleft = document.getElementById('timeleft').innerHTML; if((timeleft == HAS_EXPIRED) || (timeleft == IS_NONE)) return false; timeleft = timeleft.replace('<font>', ''); timeleft = timeleft.replace('</font>', ''); var time = timeleft.split(":"); var secs = time[2] * 1; var mins = time[1] * 1; var hrs = time[0] * 1; secs += (mins * 60) + (hrs * 3600); secs -= 1; if(secs <= 0){ document.getElementById('timeleft').innerHTML = HAS_EXPIRED; return false; } else { hrs = Math.floor(secs/3600); secs -= (hrs * 3600); mins = Math.floor(secs/60); secs -= (mins * 60); if(hrs < 10) hrs = '0' + hrs; if(mins < 10) mins = '0' + mins; if(secs < 10) secs = '0' + secs; document.getElementById('timeleft').innerHTML = hrs + ':' + mins + ':' + secs; } } setTimeout('secondCountdown(true)',1000); } bootloaderAdd('secondCountdown()'); bootloaderOn(); Cheers. Dan Similar TutorialsHi guys, I've looked around the web and tried to find a Javascript Countdown, however, the only ones I could really find were the ones that countdown to a particular date (see below). Code: <script language="JavaScript"> TargetDate = "12/31/2020 5:00 AM"; BackColor = "palegreen"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "It is finally here!"; </script> <script language="JavaScript" src="/js/countdown.js"></script> Problem is, it counts down to a particular date, and I don't want that. The reason why is because everyone's time will be different, and I want it to be a "global" countdown, fr an event happening on a website (like the launch of something). Is it possible to, other then going by date, go by days/hours/minutes/seconds? So if I enter say, 2 days, 5 hours, 0 minutes, 0 seconds, it'll start counting down EXACTLY 2 days and 5 hours, and not change per people's time zone? Any help would be greatly appreciated. If someone can point me in the right direction, or has a code already developed, I'd really appreciate it.. Thank you so much! I'm probably missing something really obvious here, but I can't figure out how to get this to work. I'm trying to get a tooltip to work, as shown he http://jquerytools.org/demos/tooltip/index.html this is where I got the basic code for the javascript and the css styling, and I've put it all together in the way that I think it should work, but instead of creating a tooltip, it basically opens the content on a separate page. Would anyone be able to look at the source code for the website below and tell me if I'm missing something here? http://boardemotion.co.uk/test.html Any help would be really appreciated Hi, I have youtube link saved as a variable with value: PHP Code: http://www.youtube.com/watch?v=oOzuBOefL8I&feature=topvideos And I need to get a part of this link which I could use later: The part would be PHP Code: oOzuBOefL8I It would be great to do it with javascript... Because I have url generated like this one: PHP Code: httpObject.open("GET", "../talpinimas.php?id=reklama&paveikslelis=" +document.getElementById('paveikslelis').value+"&pavadinimas=" +document.getElementById('pavadinimas').value+"&url1=" +document.getElementById('url1').value+"&url1name=" +document.getElementById('url1name').value+"&komentaras=" +document.getElementById('komentaras').value+"&nick=<?php echo $nick?>" , true); and I want to send just THE PART (oOzuBOefL8I) to my talpinimas.php page. If you haven't understood something or need more info ask... Thanks hey im simply tryna make a 24 hours countdown, reg ardless of timezones, computer clock etc., just a straight 24 h our stretch. here is what i have, somehow its not working, any help on fixing>? PHP Code: <script language="JavaScript"> TargetDate = 24 * 60 * 60 * 1000; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "It is finally here!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> hi all, i have written a code for simple shopping cart with 4 items.when i selecting the quantity and clicking the add to cart button it is not taking the values.it is displaying the array values what i have given.kindly tell me what is the problem and how to solve it... below is my "index.html" [HTML] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> JavaScript jQuery</title> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="js/jquery-1.6.2"></script> <script type="text/javascript"> $(document).ready(function() { // call the cart function $("#sc_cart").smartCart(); }); </script> <!--<link rel="stylesheet" type="text/css" href="css/cart.css" /> --> </head> <body> <center><h2>Select Your products</h2></center> <form method="post" action="results.php"> <div id="smartcart" class="Container"> <!-- open "contanier" class --> <div id="sc_productlist" class="ProductList"> <!-- open "ProductList" class" --> <div class="ProductListItem"> <!-- open apple Iphone --> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="images/product0.jpg" /></td> <td><strong><span id="prod_name100">Apple IPhone 3G</span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price100" style="color:red">1450.75</span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="Text" id="prod_qty100" size="3" type="text"> <input type="button" rel="100" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <!-- close apple iphone --> <hr/> <div class="ProductListItem"> <!-- open icepot --> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="images/product1.jpg" /></td> <td><strong><span id="prod_name101">Ice Pot</span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price101" style="color:red">10.25</span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="Text" id="prod_qty101" size="3" type="text"> <input type="button" rel="101" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <!-- close icepot --> <hr/> <div class="ProductListItem"> <!-- open "ProductListItem" style stand --> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="images/product2.jpg" /></td> <td><strong><span id="prod_name102">Style Stand</span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price102" style="color:red">6.15</span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="Text" id="prod_qty102" size="3" type="text"> <input type="button" rel="102" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <!-- close style stand--> <hr/> <div class="ProductListItem"> <!-- for coffee maker --> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="images/product3.jpg" /></td> <td><strong><span id="prod_name103">Coffe Maker</span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price103" style="color:red">120.35</span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="Text" id="prod_qty103" size="3" type="text"> <input type="button" rel="103" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <!-- close coffee maker --> <!-- end "ProductList" class" --> <!-- cart list--> <div id="sc_cart" class="Cart"> <select id="product_list" name="product_list[]" style="display:none;" multiple="multiple"> </select> <div class="CartListHead"> <table width='50%'> <tr> <td width='100px'>Product</td> <td width='100px'>Quantity</td> <td width='150px'>Amount($)</td> </tr> </table> </div> <div id="sc_cartlist" class="CartList"> </div> <div class="CartListHead"> <table width='100%'> <tr> <td><span id="message"></span></td> <td width='100px'>Subtotal($):</td> <td width='120px'><span id="subtotal"></span></td> </tr> </table> </div> </div> <br> <input style="width:200px;height:35px;float:right;" type="submit" class="Btn" value="Checkout"> </div> </div> </form> </body> </html> [/HTML] the array elements given here is displaying in the output.how to remove that one.below is my "results.php" Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> JavaScript jQuery</title> <!-- <link rel="stylesheet" type="text/css" href="css/cart.css" /> --> </head> <body> <center><h2>Selected Products</h2></center> <div id="sc_cart" style="width:950px;" class="Container"> <?php // creating product array $product_array = array("100" =>array('product_id'=>'100', 'product_name'=>'Apple IPhone 3G', 'product_price'=>'1450.75', 'product_img'=>'images/product0.jpg'), "101" =>array('product_id'=>'101', 'product_name'=>'Ice Pot', 'product_price'=>'10.25', 'product_img'=>'images/product1.jpg'), "102" =>array('product_id'=>'102', 'product_name'=>'Style Stand', 'product_price'=>'6.15', 'product_img'=>'images/product2.jpg'), "103" =>array('product_id'=>'103', 'product_name'=>'Coffee Maker', 'product_price'=>'120.35', 'product_img'=>'images/product3.jpg')); // get the selected product array // here we get the selected product_id/quantity combination as an array $product_list = $_REQUEST['product_list']; if(!empty($product_list)) { ?> <div class="CartListHead"> <table width='100%'> <tr> <td> Product</td> <td width='80px'>Quantity</td> <td width='130px'>Amount($)</td> </tr></table> </div> <?php $sub_total = 0; foreach($product_list as $product) { $chunks = explode('|',$product); $product_id = $chunks[0]; $product_qty = $chunks[1]; $product_name = $product_array[$product_id]['product_name']; $product_amount = $product_array[$product_id]['product_price']*$product_qty; $sub_total = $sub_total + $product_amount; ?> <div class="CartListHead"> <table width='100%'> <tr> <td> <?php echo $product_name; ?></td> <td width='80px'><?php echo $product_qty; ?></td> <td width='130px'><?php echo $product_amount; ?></td> </tr> </table> </div> <?php } ?> <div class="CartListHead"> <table width='100%'> <tr> <td><span id="message"></span></td> <td width='100px'>Subtotal($):</td> <td width='120px'><span id="subtotal"><?php echo $sub_total; ?></span></td> </tr> </table> </div> <br> <form action="index.php" method="post"> <?php if(isset($product_list)) { foreach($product_list as $p_list) { $prod_options .='<input type="hidden" name="product_list[]" value="'.$p_list.'">'; } echo $prod_options; } ?> <input style="width:200px;height:35px;float:left;" type="submit" class="Btn" value="Continue Shopping"> </form> <?php } else { echo "<strong>Your Cart is Empty</strong>"; } ?> </div> </body> </html> here too below is my "index.php"..... Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> JavaScript jQuery </title> <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { // call the cart function $("#sc_cart").smartCart(); }); </script> <!--<link rel="stylesheet" type="text/css" href="css/cart.css" /> --> <?php // creating product array $product_array = array("100" =>array('product_id'=>'100', 'product_name'=>'Apple IPhone 3G', 'product_price'=>'1450.75', 'product_img'=>'images/product0.jpg'), "101" =>array('product_id'=>'101', 'product_name'=>'Ice Pot', 'product_price'=>'10.25', 'product_img'=>'images/product1.jpg'), "102" =>array('product_id'=>'102', 'product_name'=>'Style Stand', 'product_price'=>'6.15', 'product_img'=>'images/product2.jpg'), "103" =>array('product_id'=>'103', 'product_name'=>'Coffe Maker', 'product_price'=>'120.35', 'product_img'=>'images/product3.jpg')); // get the product list $product_list = $_REQUEST['product_list']; $prod_options =''; if(isset($product_list)){ foreach($product_list as $p_list){ $prod_options .='<option value="'.$p_list.'" SELECTED></option>'; } } ?> </head> <body> <center><h2>Select Your products</h2></center> <form action="results.php" method="post"> <div id="smartcart" class="Container"> <div id="sc_productlist" class="ProductList"> <?php foreach($product_array as $p) { ?> <div class="ProductListItem"> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td rowspan="3"><img width="100px" src="<?php echo $p['product_img']; ?>" /></td> <td><strong><span id="prod_name<?php echo $p['product_id']; ?>"><?php echo $p['product_name']; ?></span></strong></td> </tr> <tr> <td><label>Price:</label> $<span id="prod_price<?php echo $p['product_id']; ?>"><? echo $p['product_price']; ?></span></td> </tr> <tr> <td><label>Quantity:</label> <input name="prod_qty" class="scText" id="prod_qty<?php echo $p['product_id']; ?>" size="3" type="text"> <input type="button" rel="<?php echo $p['product_id']; ?>" class="ItemButton Btn" value="Add Product"></td> </tr> </table> </div> <?php } ?> </div> <div id="sc_cart" class="Cart"> <select id="product_list" name="product_list[]" style="display:none;" multiple="multiple"> <?php echo $prod_options; ?> </select> <div class="CartListHead"> <table width='100%'> <tr> <td> Product</td> <td width='80px'>Quantity</td> <td width='140px'>Amount ($)</td> </tr> </table> </div> <div id="sc_cartlist" class="CartList"> </div> <div class="CartListHead"> <table width='100%'> <tr> <td><span id="message"></span></td> <td width='100px'>Subtotal ($):</td> <td width='120px'><span id="subtotal"></span></td> </tr> </table> </div> <br> <input style="width:200px;height:35px;float:right;" type="submit" class="Btn" value="Checkout"> </div> </div> </form> </body> </html> kindly tell me where went wrong and how to solve it....... Hey all - I need a java bookmarklet that does a real simple thing. I need to take the current URL (ie, where the user is when they click the bookmarklet) and append it to a static URL and return the text on the resulting page. For example: The user is at http://google.com The user clicks the bookmarklet. the bookmarklet takes http://google.com and appends it to http://example.com/outside_create.ph...ey=555&url=URL HERE where you see the URL HERE text. That PHP script echos a simple line of text (a shortened URL actually). Then I want that result from the outside_create.php file to be displayed in a window back to the user. Is this even possible? Basically I need to know how to append location.href to a static URL and how to get the resulting content from the static URL.. Hello, I understand that this question have been posted before several times. I looked at many of those threads and tried it but could not get it to work. So the idea is to use either cookies or html5 localstorage to control the java script behavior, but how do I really implement it on my code? Please help me out here on piecing all the code together. Either cookie/localstorage is fine. Thanks in advance Code: <div id='cptup-ready'> </div> <script data-cfasync='false' type='text/javascript'> //<![CDATA[ window.captain = {up: function(fn) { captain.topics.push(fn) }, topics: []}; // Add your settings he captain.up({ api_key: 'XXXXXXXX' }); //]]> </script><script data-cfasync='false' type='text/javascript'> //<![CDATA[ setTimeout(function() { var cpt = document.createElement('script'); cpt.type = 'text/javascript'; cpt.async = true; cpt.src = 'http' + (location.protocol == 'https:' ? 's' : '') + '://captainup.com/assets/embed.en.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(cpt); }, 31000)(); //]]> </script> I am wanting to display an image for 24 hours, how can I do this?
hi, I have three variables - string openTime format hh:mm - eg "08:30" - string closeTime format hh:mm eg "17:30" - float lunchHours eg 1.5 Are there any js functions I can use to calculate how many hours the shop is open ? thanks I am creating a website for someone and can get information from one form to check it so it can then change the data in another form. This what I have for JavaScript: <script type="text/javascript" language="JavaScript"> function price() { if(document.cust.top.value == None && document.cust.swirl.value == None) { document.price.hosted_button_id.value = "UDNNKUHTPGEEW"; } else { document.price.hosted_button_id.value = "CP8EVFLEASF28"; } } </script> The result I want is to take the value from my form that has a radio buttons and check to see if it equal none or not. Then using that information change the value in a different form. The first form looks like this for beginning: <form name="cust" method="get" action=""> hello you wonderful informative folks helped me make a resume site for myself some time ago i have since lost the username for ftp access to the site and remade it with paid hosting instead of free hosting, with my own domain name and everything the old site was number 2 for searching for patrick allard on google, but the new site is far down the list new site: http://patrickallardcomputerwhiz.com/ ive tried contacting the free hosting provider, trying to get him to delete the site or relink it, even giving him the password and offering $10 as i expected the customer service on free hosting isn't top notch does anyone have any ideas on how i might fix this? I have the below form where the user enters the hours and minutes worked on a task. I want to be sure that the total for the form is at least 8 hours. How can I do that? Code: <form method="POST" onSubmit="return validateHours()" name="theForm" > <p>Hours<input type="text" name="hours[]" size="20">Minutes<input type="text" name="minutes[]" size="20"></p> <p>Hours<input type="text" name="hours[]" size="20">Minutes<input type="text" name="minutes[]" size="20"></p> <p>Hours<input type="text" name="hours[]" size="20">Minutes<input type="text" name="minutes[]" size="20"></p> <p>Hours<input type="text" name="hours[]" size="20">Minutes<input type="text" name="minutes[]" size="20"></p> <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> </form> Hey everyone. I need a little help and I'm not an expert by any stretch of the imagination with javascript. I have a simple little code script and I'd like either the onClick function (or the entire code itself, whichever is easiest) to only load once every 24 hours for each IP address. So "123.1.22.333" should only get the effect of this code once every 24 hours regardless if they revisit my site 5 times a day let's say. So here's my little script: Code: <script language="JavaScript"> function goNewWin() { TheNewWin=window.open("http://google.com",'Google','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1'); TheNewWin.blur(); } </script> <body onClick="goNewWin()"> Any help would be very appreciated. Thanks! Changing Seconds to Hours in Timer Code: <script type="text/javascript"> // Javascript to compute elapsed time between "Start" and "Finish" button clicks function timestamp_class(this_current_time, this_start_time, this_end_time, this_time_difference) { this.this_current_time = this_current_time; this.this_start_time = this_start_time; this.this_end_time = this_end_time; this.this_time_difference = this_time_difference; this.GetCurrentTime = GetCurrentTime; this.StartTiming = StartTiming; this.EndTiming = EndTiming; } //Get current time from date timestamp function GetCurrentTime() { var my_current_timestamp; my_current_timestamp = new Date(); //stamp current date & time return my_current_timestamp.getTime(); } //Stamp current time as start time and reset display textbox function StartTiming() { this.this_start_time = GetCurrentTime(); //stamp current time document.TimeDisplayForm.TimeDisplayBox.value = 0; //init textbox display to zero } //Stamp current time as stop time, compute elapsed time difference and display in textbox function EndTiming() { this.this_end_time = GetCurrentTime(); //stamp current time this.this_time_difference = (this.this_end_time - this.this_start_time) / 1000; //compute elapsed time document.TimeDisplayForm.TimeDisplayBox.value = this.this_time_difference; //set elapsed time in display box } var time_object = new timestamp_class(0, 0, 0, 0); //create new time object and initialize it //--> </script> <form> <input type="button" value="Start" onClick="time_object.StartTiming()"; name="StartButton"> </form> <form> <input type="button" value="Finish" onClick="time_object.EndTiming()"; name="EndButton"> </form> <form name="TimeDisplayForm"> Elapsed time: <input type="text" name="TimeDisplayBox" size="6"> seconds </form> I am having some trouble with my code in that I am trying to take the value from the date of birth field and check to see if over 18 years old. I they are not over 18, a window.alert dialog box pops up to tell them. Any help with this I would greatly appreciate. Below is the check if 18 validation. Script section in the document head: Code: //check if over 18 function overAge(){ var age; var input = document.forms[0].birthDate.value; var pyear = parseInt(input.substring(6,10)); var pmonth = parseInt(input.substring(0,2)) - 1; var pday = parseInt(input.substring(3,5)); if ( month < pmonth ){ age = year - pyear - 1; } else if ( month > pmonth ){ age = year - pyear; } else if ( month == pmonth ){ if ( day < pday ){ age = year - pyear - 1; } else if ( day > pday ){ age = year - pyear; } else if ( day == pday ){ age = year - pyear; } } if(age < 18){ window.alert('Attention: Under 18!'); valid=false; return valid; } } Code for body section: Code: Date of Birth: <br/> <input type = "text" name = "date" value = "(mm/dd/yyyy)"/> hello everybody! this is my first atempt in writing javascript and i have a problem which I have no idea how to solve. I want to take the values from several dropdown forms and make some calculations whit those in order to display a number. Unfortunately the script responts in a way that i cannot identify what is happening. this is a shorten example of my script. Code: <html> <head> <script type="text/javascript"> function calcul() { var pcno = document.plithospc.listplpc.value; var ndno = document.plithosnd.listplnd.value; var hotline = document.hotlform.listhotl.value; var sumhotline = 0; if (hotline == 2) { sumhotline = 8*(1+0.5*pcno) + 2*(1+0.5*ndno); } else if (hotline == 3) { sumhotline = 16*(1+0.5*pcno) + 4*(1+0.5*pcno); } else { sumhotline = 0; } document.write(sumhotline); </script> </head> <body> <FORM NAME="plithospc"> <SELECT NAME="listplpc"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>-1-</OPTION> <OPTION VALUE=2>-2-</OPTION> <OPTION VALUE=3>-3-</OPTION> </SELECT> <FORM NAME="plithosnd"> <SELECT NAME="listplnd"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>-1-</OPTION> <OPTION VALUE=2>-2-</OPTION> <OPTION VALUE=3>-3-</OPTION> </SELECT> <FORM NAME="hotlform"> <SELECT NAME="listhotl"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>1st selection</OPTION> <OPTION VALUE=2>second selection</OPTION> <OPTION VALUE=3>third selection</OPTION> </SELECT> <button type="button" onclick="calcul()">click me</button> </body> does anyone knows how to fix this? thanks in advance Hello I am trying to do something similar to this post http://www.codingforums.com/showthread.php?t=168903 except I need it to be dependent on the hour and minute. Background: I am trying to create a schedule website, the schedule has say 20 items and I want it to display the current "active" event in the schedule, 1 previous event and 3 future events so a total of 5 items from the schedule. An event can range from 30 minutes to 2 hours long, so simply using the above code will not work. It needs to take the minutes into consideration as well. Let me know if you have additional questions. EDIT: 17-Mar-12 @ 12:37PM I would rather not use a bunch of if statements. (http://www.codingforums.com/showthread.php?t=250358) The schedule could change mid day so having to go through and edit a bunch of if statements would not be ideal Hi, I had a requirement in javascript.If I enter time as 12 it should automatically insert colon after hours and shoud allow user to enter minutes. First enter hours 12 while we are ready to insert minutes it should automatically insert colon as well as minutes. function autoTabTimes(input, len) { if (input.value.length == 2) { if (input.value.indexOf(":") == -1) { input.value = input.value + ":"; } var str = input.value.split(":"); if (str[0].length == 1) { input.value = "0" + str[0]; } } if (input.value.length >= len) { input.value = input.value.slice(0, len); input.form[(getIndex(input) + 1)].focus(); } return true; } The above code is working but it is not allowing user to edit the time back space is not working. Hello, I've been trying to figure this script out for awhile and I've hit a wall. Basically, what I want to do for my organization's website is to use JS to display an image containing our hours and have it change each day of the week. The hard part (for me) is that there are certain days we're closed. Ideally, I'd like a separate "We're Closed" message to overwrite the image carrying our hours on specific days (major holidays like Xmas, New Years, Vet's Day, furlough periods, etc. etc.). Here's the code I've managed to cobble together (I have a real basic understanding of JS, so I've been pulling scripts from sites offering free copy/pastecode): [CODE] <script language="javascript"> mytime=new Date(); mymonth=mytime.getMonth()+1; mydate=mytime.getDate(); myday=mytime.getDay(); arday = new Array("sunday.png", "monday.png", "tuesday.png", "wednesday.png", "thursday.png", "friday.png", "saturday.png"); document.write("<img src='" + arday[myday] + "'>"); if (mymonth==12 && mydate==24){document.write("<img src='closure.png'>"); } </script> [CODE] For the most part, this code works just fine. However, if I jump my system clock to December 24, the "closure.png" comes up appears ALONGSIDE the hours image for that day of the week. In other words, I've got two images appearing right next to each other - that's not what I want. How can I work the code in such a way that when a closure date comes up (in this case, 12/24), just the "closure.png" image shows up by itself? Thank you all so much for your time and patience. |