JavaScript - Working With Timers
Similar TutorialsHello to all. I apologise if this question has been asked before, I am banging my head off a wall and am in need of some help. I am trying to find a script (and failed, even on google) to create a countdown timer on a website. The details are : a countdown timer that (a) runs off server time, not client time and (b) resets every 10 minutes. The only example i could give to clear up any questions would be something extremely similar to facebook app games : eg mafia wars etc energy refill timers so people visiting my web page would see a countdown timer that was counting down 10 minutes and then resetting itself, on the hour, 10 past, 20 past etc etc. And also, can the counter trigger a script, orwouldit be best to use a scheduled task for this? I do not want the timer to take the user from the web page. I am not sure of the exact name of a such counter, so maybe thats why google is not giving me the answers i need. Any help would greatly be appreciated. Also I know i maybe need php to run frrom a server time. I can code php half-competently, but javascript is out of my knowledge range at present (although i can usually see code and know how to adapt it to my needs etc) Thankyou to all who can help Hi guys, hope this is the right place to post my javascript query.... Basically, I want my countup timer to start from when the page is loaded so eg 0 in all fields... This is what i have so far: 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Count?</title> <style type="text/css"> .main { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 68px; font-style: normal; font-weight: 400; color: #000; background-color: #FFF; text-align: center; } </style> <script type="text/javascript"> function showElapsedTime() { var startYear = "0"; var startMonth = "0"; // must be between 0 - 11 var startDay = "0"; // must be between 1 - 31 var startHour = "0"; // must be between 0 - 23 var startMinute = "0"; // must be between 0 - 59 var startSecond = "0"; // must be between 0 - 59 var startDate = new Date(); startDate.setYear(startYear); startDate.setMonth(startMonth); startDate.setDate(startDay); startDate.setHours(startHour); startDate.setMinutes(startMinute); startDate.setSeconds(startSecond); var rightNow = new Date(); var elapsedTime = rightNow.getTime() - startDate.getTime(); var one_day=1000*60*60*24; var elapsedDays = Math.floor( elapsedTime / one_day ); var milliSecondsRemaining = elapsedTime % one_day; var one_hour = 1000*60*60; var elapsedHours = Math.floor(milliSecondsRemaining / one_hour ); milliSecondsRemaining = milliSecondsRemaining % one_hour; var one_minute = 1000*60; var elapsedMinutes = Math.floor(milliSecondsRemaining / one_minute ); milliSecondsRemaining = milliSecondsRemaining % one_minute; var one_second = 1000; var elapsedSeconds = Math.round(milliSecondsRemaining / one_second); document.getElementById('elapsedTime').innerHTML = elapsedDays + " Days " + elapsedHours + " Hours " + elapsedMinutes + " Minutes " + elapsedSeconds + " Seconds"; t = setTimeout('showElapsedTime()',1000); } </script> </head> <body onload="showElapsedTime()"> <p class="main"> COUNT: </p> <div id="elapsedTime"></div> </body> </html> Can't quite figure out where i have gone wrong! Thanks in advance! Carl Hello all, It's my first post. I have 0 javascript knowledge and desperately need your help. I need 5 countdown timers on my html site. I would like them to countdown from different minutes (i.e. 2:30, 5:15, 1:20, etc). Here is the script I found online: Quote: <!--countdown timer --> <div style="position:absolute; overflow:hidden; left:107px; top:390px; width:40px; height:20px; z-index:18"> <script language="JavaScript"> TargetDate = new Date().valueOf() + 2*60000 + 30*1000; BackColor = "#FFFFFF"; ForeColor = "#FF6633"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%M%%:%%S%%"; FinishMessage = "SOLD!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> </div> I pasted them in the div tags and it works perfectly. However, when I copy and paste them 4 times for a total of 5 timers to display, only 1 shows. Why is this happening and how can I fix it? Here is how I it looks on my index file after I pasted it 4 times: Quote: <div id="count1" style="position:absolute; overflow:hidden; left:107px; top:390px; width:45px; height:20px; z-index:29"> <script language="JavaScript"> TargetDate = new Date().valueOf() + 2*60000 + 30*1000; BackColor = "#FFFFFF"; ForeColor = "#FF6633"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%M%%:%%S%%"; FinishMessage = "SOLD!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> </div> <div id="count2" style="position:absolute; overflow:hidden; left:257px; top:390px; width:45px; height:20px; z-index:30"> <script language="JavaScript"> TargetDate = new Date().valueOf() + 2*60000 + 30*1000; BackColor = "#FFFFFF"; ForeColor = "#FF6633"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%M%%:%%S%%"; FinishMessage = "SOLD!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> </div> <div id="count3" style="position:absolute; overflow:hidden; left:257px; top:390px; width:45px; height:20px; z-index:31"> <script language="JavaScript"> TargetDate = new Date().valueOf() + 2*60000 + 30*1000; BackColor = "#FFFFFF"; ForeColor = "#FF6633"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%M%%:%%S%%"; FinishMessage = "SOLD!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> </div> <div id="count4" style="position:absolute; overflow:hidden; left:257px; top:390px; width:45px; height:20px; z-index:32"> <script language="JavaScript"> TargetDate = new Date().valueOf() + 2*60000 + 30*1000; BackColor = "#FFFFFF"; ForeColor = "#FF6633"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%M%%:%%S%%"; FinishMessage = "SOLD!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> </div> Please help!! Sincerely, George Anyone have a script that has multi timers that will loop; Sort of like the ones used in reverse auctions. First timer 1:24:59:59 (days/h/m/s) Second timer 1:00:00 (h/m/s) Third timer 1:59 (m/s) Forth timer 59 (s) I have one now that I found here and makes no sense to me; 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" xml:lang="en" lang="en"> <head> <title></title> <font size="-4"><font face="bold"> <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ function zxctElsByClass(zxccls,zxcp,zxctag) { var zxcexa=zxccls.indexOf('=='); zxccls=zxccls.replace(' ==','').replace(/ss/g,' '); var zxcclss=zxccls.split(' '); zxcp=zxcp||document; zxcp=typeof(zxcp)=='object'?zxcp:document.getElementById(zxcp); zxctag=zxctag||'*'; var zxcels=zxcp.getElementsByTagName(zxctag),zxcary=[]; for (var zxc0=0;zxc0<zxcels.length;zxc0++){ for (var zxc0a=0;zxc0a<zxcclss.length;zxc0a++){ var zxcreg=new RegExp('\\b'+(zxcexa<0?zxcclss[zxc0a]:zxccls)+'\\b'); if ((zxcclss[zxc0a])&&zxcreg.test(zxcels[zxc0].className)){ zxcary.push(zxcels[zxc0]); break; } } } return zxcary; } function Upgrading(hrs,mins,secs){ hrs=zxctElsByClass(hrs); mins=zxctElsByClass(mins); secs=zxctElsByClass(secs); for (var zxc0=0;zxc0<hrs.length;zxc0++){ hrs[zxc0].oop=new UpgradingOOP(hrs[zxc0],mins[zxc0],secs[zxc0]) } } function UpgradingOOP(hrs,mins,secs){ this.time=[hrs,mins,secs]; this.cng(); } UpgradingOOP.prototype.cng=function(){ var hours=this.time[0].firstChild.data; var mins=this.time[1].firstChild.data; var secs=this.time[2].firstChild.data; secs=secs-1; if (secs<0){ mins=mins-1; secs=59; } if (mins<0){ hours=hours-1; mins=59; secs=59; } if (hours<0) { hours=0; mins=0; secs=0; this.time[0].firstChild.data=hours; this.time[1].firstChild.data=mins; this.time[2].firstChild.data=secs; window.location = document.URL; } if (mins>=0) { mins=mins-1; mins=mins+1; if (secs<10) secs="0"+secs; if (mins<10) mins="0"+mins; this.time[0].firstChild.data=hours; this.time[1].firstChild.data=mins; this.time[2].firstChild.data=secs; this.to=setTimeout(function(zxcoop){return function(){zxcoop.cng();}}(this),1000); } } /*]]>*/ </script></head> <table align=\"left\" width=\"50\" height=\"50\" border=\"0\" bgcolor=\"ltblue\"> <tr> <td><label class='uHours' >1</label>: <label class='uMins'>1</label>: <label class='uSecs'>1</label></td> <td><label class='uHours' >1</label>: <label class='uMins'>1</label>: <label class='uSecs'>1</label></td> <td><label class='uHours'>1</label>: <label class='uMins'>1</label>: <label class='uSecs'>1</label></td> </tr> </table> <br /> <table align=\"left\" width=\"50\" height=\"50\" border=\"0\" bgcolor=\"ltblue\"> <tr> <td><label class='uHours' >1</label>: <label class='uMins'>1</label>: <label class='uSecs'>1</label></td> <td><label class='uHours' >1</label>: <label class='uMins'>1</label>: <label class='uSecs'>1</label></td> <td><label class='uHours'>1</label>: <label class='uMins'>1</label>: <label class='uSecs'>1</label></td> </tr> </table> <script type="text/javascript">Upgrading('uHours','uMins','uSecs');</script> </font></font> </body> </html> This is my first post and hope someone can show me how to have JavaScript wait until a function has completed before moving on? I tried a timer, but the database does not always came back with data durning the time alloted. Thank you for any help. Code: function RunMerch() //Reprompt script { var fW = (typeof getFormWarpRequest == 'function' ? getFormWarpRequest() : document.forms['formWarpRequest']); if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );} //fW._oLstChoicesMyFieldName.selectedIndex = 0; var preFix = ''; if (fW.elements['cv.id']) { preFix = fW.elements['cv.id'].value; } setTimeout('oCV' + preFix + '.promptAction(\'reprompt\')', 1000); { //Call val () function -- This is where I want it to complete the reprompt function before moving on val(); } } // This will run the valtradselection() function function val() { valtradselection(); } I hope I have this post in the right place! Any help would be very much appreciated... I have a feature on my website that allows users to choose the website background (using alternate css sheets) and then uses an externally linked javascript file to store the background choice as a cookie so it is consistent throughout the website. This works perfectly locally (i.e. when previewing my website on my computer) but now it is uploaded to my host it doesn't appear to be working. (with the same browser) My javascript is he http://www. b r p - e n v .com/javascript/backgroundchange.js (with no spaces) The website that the javascript file is linked to is http://www. b r p - e n v .com (with no spaces) In the head I have: <script type="text/javascript" src="../javascript/backgroundchange.js"></script> ...then I have: <body onload="set_style_from_cookie()"> ...and for users to choose which background: <form> <input type="image" src="../images/white-background-thumb.jpg" onclick="switch_style('bg1');return false;" name="theme" value="White" id="bg1"> etc... </form> My problem is: The background reverts back to the default when moving to a different page. This would indicate that the background choice is not being saved in cookies. But this works locally! I have tried putting the javascript directly onto each page but I still had the same problem. I hope someone can help, I will be so grateful if I can get this to work. Many thanks indeed! Ok, here's the page as it is right now: http://www.crackin.com/dev/index.php The paganation for the top 3 images is Sweet Pages: http://tutorialzine.com/2010/05/swee...tion-solution/ The content loading below is a page-replace script I got he http://css-tricks.com/dynamic-page-replacing-content/ And I'm also trying to integrate shadowbox (or lightbox, whichever will work) into the lower set of images. I have 2 problems right now I can't figure out, and I'm sure it somehow has to do with the fact I'm trying to mash 3 different JS addons into a single page, I'm still pretty new to this whole JS thing... First problem I'm having is that IE7 and Opera don't like the links in the upper images. Clicking a gallery image does not load the associated page below from those 2 browsers, however IE8 and FF seem to work fine. Second problem is getting shadowbox/lightbox to work on those lower images. I tried a couple different things but main thing I did is make sure the script is actually working by setting the header text to a link with shadowbox attached and that worked. That same link doesn't work when applied to the lower images (loads image in new window). Lightbox does the same thing. Thanks for any help. Hi All, I have two sites using zeroclipboard (hosted at google code) one works only in firefox and barely, the other is not working at all. It does use Flash, but I think the issue is on the js side of things. On both links, clicking the filename below the thumbnail will copy and add the link as an IMG code to a div below. *working* link http://pics.boasbysatyra.com/access/spiders.php This one only works in FF, and the clip area is offset badly. Here is the template for the zc code: Code: <div class="photo" style="float: left; padding: 4px;"> <div class="exif"><a href="[~41~]?dir=[+images_dir+]&file=[+filename+]" rel="shadowbox[exif_[+content_id+]]" title="exif data for [+filename+]" alt="exif data for [+filename+]">EXIF Data</a></div> <a class="thumb" rel="shadowbox[[+content_id+]]" href="[+images_dir+][+filename+]" title="[+title+] | [+description+]"> <img src="[+thumbs_dir+][+filename+]" alt="[+title+]" /> </a> <div class="filecode" id="d_clip_button[+filename+]">[+filename+] <script language="JavaScript"> var clip = new ZeroClipboard.Client(); clip.setText( 'http://pics.boasbysatyra.com[+images_dir+][+filename+]' ); clip.glue( 'd_clip_button[+filename+]' ); clip.addEventListener( 'onComplete', my_complete ); function my_complete( client, text ) { $('.picklist').append('<div class="piclinks">[IMG]' + text + '[/IMG]</div>'); } </script> </div> </div> And the JS for the page: Code: var needRef; //flag for page reload function pEdit(){ needRef = 1; } Shadowbox.init({ handleOversize: "resize", modal: true, initialHeight: 32, initialWidth: 400, overlayOpacity: 0.85, onClose: function(){//check for reload flag and reload if (needRef == 1){window.location.href=window.location.href;} } }); ZeroClipboard.setMoviePath('/js/zc/ZeroClipboard10.swf'); function initMenu() { $('#menu ul').hide(); $('#menu ul:first').show(); $('#menu li a').click(function() { var checkElement = $(this).next(); if ((checkElement.is('ul')) && (checkElement.is(':visible'))) { //return false; } if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) { $('#menu ul:visible').slideUp('normal'); checkElement.slideDown('normal'); return false; } }); } $(document).ready(function() { initMenu(); }); Now on to the totally broken one - it creates the elements required, but gives them a 0x0 area! http://jb.boasbysatyra.com/forum-pic...cs/nature.html Code: div class="photo" style="float: left; margin: 4px;"> <div class="exif"><a href="[~133~]?dir=[+images_dir+]&file=[+filename+]" rel="shadowbox[exif_[+content_id+]]" title="exif data for [+filename+]" alt="exif data for [+filename+]">EXIF Data</a></div> <a class="thumb" rel="shadowbox[[+content_id+]]" href="[+images_dir+][+filename+]" title="[+title+] | [+description+]"> <img src="[+thumbs_dir+][+filename+]" alt="[+title+]" /> </a> <div id="d_clip_container[+filename+]" style="position:relative; width: 120px; height: 0.5em;"> <div class="filecode" id="d_clip_button[+filename+]">[+filename+] <script language="JavaScript"> var clip = new ZeroClipboard.Client(); clip.setText( 'http://jb.boasbysatyra.com[+images_dir+][+filename+]' ); clip.glue( 'd_clip_button[+filename+]','d_clip_container[+filename+]' ); clip.addEventListener( 'onComplete', my_complete ); function my_complete( client, text ) { $('.picklist').append('<div class="piclinks">[IMG]' + text + '[/IMG]</div>'); } </script> </div> </div> </div> On this one I wrapped it as suggested on the zc site, I originally started with the code for the other site - it didn't work, so I went tweaking... Here is the JS: Code: var needRef; //flag for page reload function pEdit(){ needRef = 1; } Shadowbox.init({ handleOversize: "resize", modal: true, initialHeight: 32, initialWidth: 400, overlayOpacity: 0.85, onClose: function(){//check for reload flag and reload if (needRef == 1){needRef = 0; window.location.href=window.location.href;} } }); ZeroClipboard.setMoviePath('/js/zc/ZeroClipboard10.swf'); $(document).ready(function() { $(".dim img").fadeTo("slow", 0.65); $(".dim img").hover(function(){ $(this).fadeTo("slow", 1.0); },function(){ $(this).fadeTo("slow", 0.65); }); $('#mainContent').hide().fadeIn(1200); //When page loads... $(".tab_content").hide(); //Hide all content // $("ul.tabs li:first").addClass("active").show(); //Activate first tab // $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); }); (function($) { $(document).ready(function(){ $('.menu1').ptMenu(); $('.menu2').ptMenu({vertical:true}); }); })(jQuery); I have taken a look at this for a few days and tried many things with no luck, any help is appreciated. Thanks! I have a usercontrol which get inputs from the user and show the slideshows. I have added jquery.js and jqfancytransitions.js to the control. when i apply the effects dynamically it is working on local iis but the same coding is not working on iis server. The link for the page is http://www.gloriatech.com/slideshow.aspx . Actually it display the images but no effects are applied. I also checked the js files, it is in right path only.When i checked this page in firebug , it shows the error which is " Sys is undefined". I dont know how to solve it. Can anyone help me? Thanx in advance. hereis the html file and javascripton click of this button a html ***************************** <table class=matcolor id=topnav cellspacing=0 cellpadding=0 width=550 border=0 bgcolor="#FFCCCC"> <tbody> <tr align=middle> <td id=menu1 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Desk Top Publishing </font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu2 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Transcription</font></div> </td> <td width=1 bgcolor=#ff9900 class="mat"></td> <td id=menu3 onMouseOver="this.className='mPrimaryOn';showmenu(this);" onClick="this.document.location.href=''" onMouseOut="this.className='mPrimaryOff';hidemenu(this);" class="mat" height="20"> <div align="center"><font color="#FF0000">Accounts Processing </font></div> </td> </tr> </tbody> </table> ***************************************** <script language=JavaScript> ix = document.getElementById('tblmenu1').getBoundingClientRect(); new ypSlideOutMenu("menu1", "right",ix.left + ix.right ,ix.bottom + 10); </script> **any thing i have to alter to work in firefox please help hi jus want to ask why is the else not working in the showmore and showless function i have two div which shld conduct the same way of working which is to show the rest of the text with the show more and min the text with the show less function anyone know what my mistake is? Code: function showmore() { if (document.getElementById("mydiv1") ){ document.getElementById("mydiv1").innerHTML = ""; document.getElementById("mydiv1").innerHTML = txt1 + "<font color = '#0000FF' size = '1'><a onclick='showless();return false'>.....read less</a>";txt1; } else { document.getElementById("mydiv").innerHTML = ""; document.getElementById("mydiv").innerHTML = txt + "<font color = '#0000FF' size = '1'><a onclick='showless();return false'>.....read less</a>";txt; } } function showless() { if (document.getElementById("mydiv1")){ document.getElementById("mydiv1").innerHTML = shorttxt1 + "<font color = '#0000FF' size = '1'><a onclick='showmore();return false'>.....read more</a>"; } else { document.getElementById("mydiv").innerHTML = shorttxt + "<font color = '#0000FF' size = '1'><a onclick='showmore();return false'>.....read more</a>"; } } thanks Reply asap!!! Can you please take a look at this and tell me why it is not getting all the way thru the function and why this is not working totally. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <script type="text/javascript"> function cabFair(start, end, time){ var base = 0; if (start = 1){ if (end = 1){ base = 5; }if (end = 2) { base = 7; }base = 8; }if (start = 2){ if (end = 1){ base = 7; }if (end = 2) { base = 5; }base = 9; }if (end = 1){ base = 8; }if (end = 2) { base = 9; }base = 5; //return(base); if (time > 20){ time1 = (time - 20); time2 = (time1 * (.3)); finalTime = (time2 + 10); }if (time > 10 && time <= 20){ time1 = (time - 10); time2 = (time1 * (.4)); finalTime = (time2 + 6); }if (time >4 && time <= 10){ time1 = (time - 4); time2 = (time1 * (.5)); finalTime = (time2 + 3); }finalTime = (time * .75); var fare = finalTime + base; return fare } </script> </head> <body> <script type="text/javascript"> //Ask user for input var start = parseInt(prompt("Enter the Starting Point", "1")); var end = parseInt(prompt("Enter the Ending Point", "2")); var time = parseInt(prompt("Enter the Total Time", "4")); //output for information document.writeln(cabFair(start, end, time) + " Is the Total Fare."); </script> </body> </html> Script::. Code: <script language="javascript"> function temp(form) { oops = ""; var sum = 0; var fld = (form.level.value); var val = fld.value.replace(/\s/g, "" ); if ( val != "") { var deg = parseFloat(fld.value); if ( isNaN(deg) || deg < 0) { fld.value = "0"; oops += "\nInvalid Level"; } else if ( deg != 0 ) { sum += Math.pow( deg, 3 );} } if ( oops != "" ) { alert("You must correct these errors:\n" + oops); return false; } form.totalexp.value = sum ; } </script> Html::. Code: <form style="text-align:center"> <p>Level</p> <p><input size=30 maxlength=30 value=0 name="level" onfocus="this.value=''"/></p> <input type=button onclick=temp(this.form) value=Calculate /> <input type=reset name=clear id=clear value=Clear /></p> <blockquote><p>Total Exp <input name="totalexp" size=40 maxlength=40 readonly=""/></p></blockquote></form> Can someone help me. Whats wrong with my js code and i am noob to J.S. Your help is most appreciated. This is not working, any idea ? Code: function respuestas1() { var radios=document.getElementsByTagName("input"); var values; for (var i=0; i<radios.length; i++) { if (radios[i].type==="radio" && radios[i].checked) { values=radios[i].value; sum = 0; for (var i=0; i<values.length; i++) { sum = sum + Number(values[i]); alert(sum); } } } } I think that if there is more space between the columns that it would be easier to read, but whatever I try is not working. Just putting tabs between them is my latest idea, however, the space is not all that big. Is it possible that I have entered it wrong? Thank you, the code is below: <html> <head> <title>Exercise</title> <script type = "text/javascript"> <!-- var row = 0; var cols = 0; var sum = (row + 1); if (row ==0) { document.write("sum   square   cube"); document.write("<br>"); row++; } while((row >= 0) && (row <= 11)) { document.write(row + "\t" + (row * row) + "\t" + (row * row * row)); document.write("<br>"); row++; } // --> </script> </head> <body> <p>what? seriously, this is working?</p> </body> </html> HI, i know this must be old js because 'language' is deprecated but, I would like to know where this script gets the word 'Name:' from for the output after I entered dat to the textbox. Code: <HTML> <HEAD> <script language="javascript"> <!-- function send_onclick(frmName) { var bolSubmit; bolSubmit = true; if (frmName.email.value == "") { alert("You must enter an email address"); bolSubmit = false; } if (bolSubmit == true) { frmName.submit(frmName); } } //--> </script> </HEAD> <BODY> <form name="frmName" method="post" action="validate.asp"> Enter your name in the text box. If nothing is entered, a warning message will be displayed. <br>Only when you enter something into the text box will the page be submitted. <br><br> Please enter your name : <INPUT TYPE="TEXT" name="email" size="20"><br> <INPUT TYPE="button" name="butSent" value="Do it" language="javascript" onclick="return send_onclick(frmName)"> </form> Name : d </BODY> </HTML> I guess its from the 'name' of name='email' but how does it do it. Is this next part grabbing everything that was submitted as if a key/value pair? Code: if (bolSubmit == true) { frmName.submit(frmName); } bazz In my website, I have a script that I need help to get working. This is my script. Code: <script language="Javascript"> <!-- if (screen.width>=1024) { document.write('<td width="20%"><table border="0" cellpadding="0" cellspacing="0" width="162"> <tr><td height="29" style="background:url("/Custom/Top2.png");color:#116111;" align="center"><b>Newest Tutorial</b></td></tr> <tr><td height="160" style="background:url("/Custom/Middle2.png") #000000;padding:5px 5px 0 5px;">$MYINF_8$</td></tr> <tr><td><img src="/Custom/Bottom2.png" border="0"></td></tr> </table> </td>'); } //--> </script> It is supposed to detect if someone has a widescreen monitor, and then add the extra box if it is widescreen. For some unknown reason, its not working. No extra box appears. Does anyone know where I went wrong? Edit: $MYINF_8$ is what goes inside the box. Hi guys, For some reason, in IE8, on product pages (Example) of my ecommerce site, the 'Size Chart' and 'Email to a Friend' popups don't work, and the product image lightbox won't work either. I have turned pop-up blocker off but they still don't work. These popups work in every other browser I have tested in, including IE7. It seems to only be IE8 that is having this problem. Here is the HTML: Code: <div class="row "> <label >Size: </label> <strong class="fl"><select name="size" id="size" onchange="checkstock(this.value)"><option value="">Select Size</option><option value="S">S</option><option value="M">M</option><option value="L">L</option><option value="XL">XL</option><option value="XXL">XXL</option></select></strong> <span style="text-decoration: underline;" class="size_chart more" title="size_chart1">+ Size Chart</span> <div style="display: none;" class="size_chart1 hide" > <div class="close"></div> <img src="http://www.projectdisobey.com/disobeyclothing/wp-content/themes/eCommerce3/images/size_chart.jpg" alt="" /> </div> <!-- size chart --> </div> Code: <ul class="fav_link"> <li class="print"> <a href="#" onclick="window.print();return false;">Print</a> </li> <li class="rss"> <a href="http://feeds.feedburner.com/DisobeyClothing">RSS</a> </li> <li class="emailtofriend"> <span style="text-decoration: underline;" class="more" title="tellafrnd_div">Email to a Friend</span> <span id="tellafrnd_success_msg_span"></span> <div style="display: none;" id="tellfrnddiv" class="tellafrnd_div hide"> <iframe src="http://www.projectdisobey.com/disobeyclothing/?page=tellafriend_form&pid=402" style="border: medium none ; width: 547px; height: 558px;" frameborder="0" ></iframe> </div> </li> <li class="share"> <div class="a2a_kit addtoany_list"> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.projectdisobey.com/disobeyclothing/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/> </a> </div> <script type="text/javascript"><!-- var a2a_config = a2a_config || {}; a2a_config.linkname="Know Your Enemy"; a2a_config.linkurl="http://www.projectdisobey.com/disobeyclothing/?p=402"; a2a_config.color_main = "f3f3e7";a2a_config.color_border = "C0C88A";a2a_config.color_link_text = "332402";a2a_config.color_link_text_hover = "332402";a2a_config.color_bg = "7f6f2"; a2a_config.num_services = 14; //--></script><script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script> </li> </ul> Here is the Javascript: Code: <script type="text/javascript"> var closebutton='<?php bloginfo('template_directory'); ?>/library/js/closebox.png'; </script> <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/library/js/fancyzoom.js"></script> <script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('div.photo a').fancyZoom({scaleImg: true, closeOnClick: true}); $('#medium_box_link').fancyZoom({width:400, height:300}); $('#large_box_link').fancyZoom(); $('#flash_box_link').fancyZoom(); }); </script> <script type="text/javascript"> /* <![CDATA[ */ $(document).ready(function(){ $('.hide').hide(); $('body').append('<div id="infoBacking"></div><div id="infoHolder" class="large"></div>'); $('#infoBacking').css({position:'absolute', left:0, top:0, display:'none', textAlign:'center', background:'', zIndex:'600'}); $('#infoHolder').css({left:0, top:0, display:'none', textAlign:'center', zIndex:'600', position:'fixed'}); if($.browser.msie){$('#infoHolder').css({position:'absolute'});} $('.more').mouseover(function() {$(this).css({textDecoration:'none'});} ); $('.more').mouseout(function() {$(this).css({textDecoration:'none'});} ); $('.more').click(function(){ if ($('.' + $(this).attr("title")).length > 0) { browserWindow() getScrollXY() if (height<totalY) { height=totalY; } $('#infoBacking').css({width: totalX + 'px', height: height + 'px', top:'0px', left:scrOfX + 'px', opacity:0.85}); $('#infoHolder').css({width: width + 'px', top:scrOfY + 25 + 'px', left:scrOfX + 'px'}); source = $(this).attr("title"); $('#infoHolder').html('<div id="info">' + $('.' + source).html() + '<p class="clear"><span class="close"><?php _e('Close X');?></span></p></div>'); $('#infoBacking').css({display:'block'}); $('#infoHolder').show(); $('#info').fadeIn('slow'); } $('.close').click(function(){ $('#infoBacking').hide(); $('#infoHolder').fadeOut('fast'); }); }); /* find browser window size */ function browserWindow () { width = 0 height = 0; if (document.documentElement) { width = document.documentElement.offsetWidth; height = document.documentElement.offsetHeight; } else if (window.innerWidth && window.innerHeight) { width = window.innerWidth; height = window.innerHeight; } return [width, height]; } /* find total page height */ function getScrollXY() { scrOfX = 0; scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ) { scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } totalY = (window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null); totalX = (window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null); return [ scrOfX, scrOfY, totalY, totalX ]; } return false; }); /* ]]> */ </script> Anybody have any suggestions as to what the problem might be (and how I can rectify it)? If you need more info, please let me know... Thanks! I am trying to use "&&" like in PHP, but JavaScript doesn't like it: Code: if (document.forms["form"]["30"].value == "" && document.forms["form"]["32"].value == "") {foobar;} So, if both these conditions are true, then foobar. Does anyone know why it doesn't work? |