JavaScript - Getting Past The Ie7/8 Incomplete Forms After Back
Yeah, did that title confuse you? :P
I realize there is a problem with forms in IE7 and 8, where when a form is submitted, and you click the Back button or use history.go(-1), dynamic elements are not properly shown with their previous values. I can save the forms data to cookies for future use, but when I try to go Back, the page isn't actually reloaded, so the script won't load the cookies. How can I force a reload of the previous page upon going Back? Similar TutorialsI'm trying to make a site where when you click the submit button it puts an asterisk next to all of the incomplete fields while also displaying an alert box. I'm having no luck with it so far since I don't know how to get a script to print something to a specific part of a page. Here is what the whole thing looks like so far. I tried using page-jumping but that didn't work: Code: <html> <head> <title>Sortomatic 5000 </title> <script type="text/javascript"> function Sort(form){ var fruits = [form.One.value, form.Two.value, form.Three.value]; if (form.One.value!=""&&form.Two.value!=""&&form.Three.value!=""){ document.writeln(fruits.sort()); } if(form.One.value=""){ alert("Please enter at least one character into all fields."); parent.location='#first'; document.writeln("*"); } if(form.Two.value=""){ alert("Please enter at least one character into all fields."); } else{ alert("Please enter at least one character into all fields."); } } </script> </head> <body> <form name="Sortform" > <input type="text" name="One"><A NAME="first"></A><br> <input type="text" name="Two"><br><A NAME="second"></A> <input type="text" name="Three"><br><A NAME="third"></A> <input type="submit" onClick="Sort(this.form)"> </form> </body> </html> Hi I'm reading a text file, manipulating the string that I've read, and then writing to a new text file called temp. The error that I am getting is basically reading past the end of the file. function SpaceFileEntries() { fso = new ActiveXObject("Scripting.FileSystemObject"); filename = "NDELPROF.txt"; path1 = document.getElementById("lblDataOutputDirectory").innerText + "\\" + filename; path2 = document.getElementById("lblDataOutputDirectory").innerText + "\\temp.txt"; s = fso.OpenTextFile(path1); j = fso.CreateTextFile(path2 , true); do { text = s.readLine(); partOne = text.substring(0,34); lastPart = text.substring(35, 54); space = " "; j.write(partOne); j.write(space); j.writeline(lastPart); } while ( text != null ) s.Close(); j.Close(); } Can someone please help me find this bug in the code. I know it's got to do with the while statement, but can't think or find good alternatives. Thanks. Daniel hi, anyone knows how to get the past 6th month date using time difference? like if the current date is given 18-April-2011 then the past 6th month date is 18-October-2010...how can this be done by using time difference? Thanks, verve I am trying to create a drop down menu for dates that starts with today's date, but allows people to choose 50 years into the past and 10 years into the future. Here's what I have for the years: 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>Untitled Document</title> </head> <body> <h4>Select a date to see the energies for that day <script type="text/javascript"> var mesparaluna=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec']; function populatedropdown(mesparaluna, diaparaluna, axxa1){ var today=new Date() var mesparaluna=document.getElementById(mesparaluna) var diaparaluna=document.getElementById(diaparaluna) var axxa1=document.getElementById(axxa1) for (var i=0; i<31; i++) diaparaluna.options[i]=new Option(i, i+1) diaparaluna.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day for (var m=0; m<12; m++) mesparaluna.options[m]=new Option(mesparaluna[m], mesparaluna[m]+1) mesparaluna.options[today.getMonth()]=new Option(today.getMonth(), today.getMonth(), true, true) //select today's month var thisyear=today.getFullYear() for (var y=0; y<20; y++){ axxa1.options[y]=new Option(thisyear, thisyear) thisyear+=1 } axxa1.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year } </script> <script> sacakindias() </script> <SCRIPT SRC=tzolkin.js></script> <script> armatzolkin() </script> <p><font size="2" face="Verdana"> <SELECT class="input_tex" name=mesparaluna id="mesparaluna"></SELECT> </font> <SELECT class="input_tex" name="diaparaluna" id="diaparaluna"></SELECT> </font> <SELECT class="input_tex" name="axxa1" id="axxa1"></SELECT></p> <p><INPUT class="input_tex" onclick="sacakinpersonal()" type="button" value="Search"><img border="0" name="pirav" src="blanco.gif" class="shakeimage" width="10" height="10"> <INPUT class="input_tex" onclick="sacakindias()" type="button" value="Today"></p></form> <script type="text/javascript"> //populatedropdown(id_of_day_select, id_of_month_select, id_of_year_select) window.onload=function(){ populatedropdown("diaparaluna", "mesparaluna", "axxa1") } </script> </h4> </body> </html> I am also having a problem with the month. I wanted it to show the name of the month, but I am getting a number (and a wrong one at that). Apologies... I am a terrible newbie with Javascript. Hello, I have a bit of javascript that is supposed to change picture and its accompanying text when you hover over a bit of link text in another area of the page. This is working, however, the text is toggling without the picture due to an invisible area next to each link. I am not sure if it's an issue with applying my javascript to another bit of code or what. Here is the code that I have that flips the text: Code: <script type="text/javascript"> function tabOver(which) { for ( var d = 1; d <= 31; ++d ) { document.getElementById("TAB"+d).style.display = ( d == which ) ? "block" : "none"; } } </script> and here is the bit that flips the pics: Code: <script> function changeimage(towhat,url){ if (document.images){ document.images.targetimage.src=towhat.src gotolink=url } } function warp(){ window.location=gotolink } </script> <script language="JavaScript1.1"> var myimages=new Array() var gotolink="#" function preloadimages(){ for (i=0;i<preloadimages.arguments.length;i++){ myimages[i]=new Image() myimages[i].src=preloadimages.arguments[i] } } preloadimages("photos/aes1.jpg","photos/aes2.jpg","photos/aes3.jpg","photos/aes4.jpg","photos/aes5.jpg") </script> And here is the html where they show up: Code: <div id="mainimg-staff"><a href="javascript:warp()"><img src="img/select-aes.gif" name="targetimage" border=0></a> <div id="TABHOLDER"> <div id="TAB1" class="tabbed" style="display: block;"> </div> <div id="TAB2" class="tabbed"> <h1>Cheryl Lyon</h1> <ul> <li> Basic facials and skin treatments <li> Waxing <li> Specializing in naturopathic facial treatments </ul> </div> <div id="TAB3" class="tabbed"> <h1>Jackie T.</h1> <ul> <li> 10+ years experience <li> Facials and skin treatments <li> Waxing <li> Specializing in <em>Extreme</em> eyelash extensions </ul> </div> (there are a lot more text bits but I only included 2 to keep this short) Finally, here is the link that is making all this wonderful stuff happen: Code: <div style="left: 100px;" onmouseover="tabOver(2);"><a href="staff-aes.shtml" onMouseover="changeimage(myimages[0],this.href)">Cheryl Lyon</a></div> Do you see how I combined the pic and text in one code? I promise you that it is on accident that this is working at all. Could this be a style issue and not a javascript issue? I can't find anything in my css that will fix this. I'm using the autofill forms plugin for firefox which can be found he https://addons.mozilla.org/en-US/firefox/addon/4775 I use it to automatically fill various web forms, duh. But I would like certain values to be chosend randomly from a list I create. I contacted the developer and he said the add on probably does not need a new feature because there is a 'dynamic tags' function to fill certain forms with dynamic values (e.g. the current time or date). He has given over the project to another developer and told me I probably would find a solution in a good javascript programming forum. So here I am! Can anyone help me with this? Basically, I just need a javascript code which chooses on item from an array randomly, I guess? I'm not a programmer myself, so any help would be greatly (!) appreciated. Thanks a lot in advance for any further guidance! Note: Here are sample dynamic tags from the plugin: <datetime> new Date().toLocaleString() <useragent> navigator.userAgent <langcode> navigator.language <resolution> screen.width+'x'+screen.height <clipboard> this.getClipboardText() Hi, I have a webpage with a world clock. On the clock page are 12 buttons (World Cities). When the user clicks these buttons. The time for the relevant world city is displayed. (The time is updated by an on.click function for each individual button. That either subtracts or adds the hours from GMT. For example. If the time is GMT 18:00:00. The user clicks the Paris button and the function adds 1 hour to result in 19:00:00) However. If the GMT time is for example 21:00:00 and the user clicks the Tokyo button (GMT+9 hours). The time displayed is 30:00:00. So I have been trying to work out how I can stop the time adding past 23:59:59. This is probably so simple which is probably why I cant find any help online. It has stumped me and any help would be appreciated. I have copied and pasted my code below in the hope that helps. Thanks in advance if you can offer any advice. Code: <script> function start() { GMToffset = 0; t=setInterval('digitalclock()',500); } function digitalclock() { var today=new Date(); var hours=today.getHours() + GMToffset; var minutes=today.getMinutes(); var seconds=today.getSeconds(); minutes=checkTime(minutes); seconds=checkTime(seconds); hours=checkTime(hours); document.getElementById('txt').innerHTML=hours+":"+minutes+":"+seconds; } function checkTime(i) { if (i<10) { i="0" + i; } return i; } function updatetime1() { GMToffset = -3; } function updatetime2() { GMToffset = -4; } function updatetime3() { GMToffset = -7; } function updatetime4() { GMToffset = -10; } function updatetime5() { GMToffset = -11; } function updatetime6() { GMToffset = -13; } function updatetime7() { GMToffset = +9; } function updatetime8() { GMToffset = +8; } function updatetime9() { GMToffset = +7; } function updatetime10() { GMToffset = +1; } function updatetime11() { GMToffset = +0; } function updatetime12() { GMToffset = +3; } </script> <div align="center"> <input type="button" onclick="updatetime1()" value="Time in Buenos Aires" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime2()" value="Time in New York" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime3()" value="Time in San Francisco" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /><br> <input type="button" onclick="updatetime4()" value="Time in Hawaii" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime5()" value="Time in Fiji" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime6()" value="Time in Sydney" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /><br><br> <body onload="start()"> <div id="txt"></div> </div> <div align="center"> <input type="button" onclick="updatetime7()" value="Time in Tokyo" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime8()" value="Time in Hong Kong" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime9()" value="Time in Bangkok" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /><br> <input type="button" onclick="updatetime10()" value="Time in Rome" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime11()" value="Time in London" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime12()" value="Time in Moscow" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> Not sure if this is possible in javascript: I'm looking for two different dates (bill date and due date) on an invoice that are captured by OCR. If one of them exists, but the other does not, I want the empty field to be 14 days before (or after) the other. For example: if the bill date is 7/27/2010 and the due date was not captured, I want to set the due date as 8/10/2010 (14 days after the bill date). If the due date was captured as 8/10/2010, but the due date is blank, I want to assign the bill date as 7/27/2010 (14 days before the due date). if both dates have values, do nothing. Thanks. i have the following code which i am trying to insert a 'back button' into to go back to the previous page. i can only seem to get the button to appear either at the very top or very bottom of the page, does anyone know how i can specify the location? this script is generated from easypano tourweaver - Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Virtual Tour Created By CAPITA SYMONDS</title> </head> <body leftMargin="0" topMargin="0" rightMargin="0" bottomMargin="0"> <script type="text/javascript" src="swfobject.js"></script> <div id="flashcontent"> To view virtual tour properly, Flash Player 9.0.28 or later version is needed. Please download the latest version of <a href="http://www.adobe.com/go/getflashplayer" target="_blank">Flash Player</a> and install it on your computer. </div> <script type="text/javascript"> // <![CDATA[ var so = new SWFObject("twviewer.swf", "sotester", "1024", "768", "9.0.0", "#FFFFFF"); so.addParam("allowNetworking", "all"); so.addParam("allowScriptAccess", "always"); so.addParam("allowFullScreen", "true"); so.addParam("scale", "noscale"); //<!-%% Share Mode %%-> so.addVariable("lwImg", "resources/2_area_multipix_preloading image file.jpg"); so.addVariable("lwBgColor", "255,255,255,255"); so.addVariable("lwBarBgColor", "255,186,186,186"); so.addVariable("lwBarColor", "255,153,0,0"); so.addVariable("lwBarBounds", "-512,-384,1024,768"); so.addVariable("lwlocation", "4"); so.addVariable("lwShowLoadingPercent", "false"); so.addVariable("lwTextColor", "255,0,0,0"); so.addVariable("iniFile", "config_2_Area_Multipix.bin"); so.addVariable("progressType", "1"); so.addVariable("swfFile", "resources/2_area_multipix_1_animation for tourweaver.swf"); so.addVariable("href", location.href); so.write("flashcontent"); // ]]> </script> </body> </html> here is the button code - Code: <span onclick="javascript:history.back()" style="text-decoration:underline; color:blue; cursor:hand">Back</span> Not sure how to explain this but...... Using a meta refresh to display a thankyou page for 5 seconds after a form submit, then return to form. If user clicks back to return to main page from form, returns to thankyou page instead, and has to go back to form again, then back to main page. I can have thankyou page return to main page, but would rather return to form. This is what it should do: main page -> form -> thankyou page -> form -> main page This is what it does: main -> form -> thankyou -> form -> thankyou -> form -> main Is there any way to remove thankyou page from history? I need an html page that when visited automatically redirects the browser to return to the previous page it was on. here is the current code I have: Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script type="text/javascript"> function load() { history.go(-1) alert(""); } </script> </head> <body onload="load()"> <input type="button" value="Back" onclick="goBack()" /> </body> </html> this works in firefox but in IE you have to press ok in the alert box before it returns. I admit I am a javascript novice. Any suggestions Hello kind folk of codingforums.com! I am pretty new to JS and have been racking my brain all week to find a solution for this. I have a javascript fading slideshow but it has no back or next button. I'm not sure if i need to add another function or go about it a different way. Here is the code if anyone can help. Thanks in advance!!! <script type="text/javascript"> var slidespeed=5800 var slideimages=new Array("my_images/SBDCslide.gif","my_images/americanbuilding.gif","my_images/emerald.gif", "my_images/nautical.gif", "my_images/rent.gif","my_images/allyn.gif","my_images/SBDCslide.gif","my_images/signs.gif","my_images/cobalt.gif","my_images/test.gif","my_images/federal.gif") var slidelinks=new Array("#" ,"american.asp","emerald.asp","nautical.asp") var whichlink=0 var whichimage=0 var imgobj, filtersupport, blenddelay var imageholder=new Array() for (i=0;i<slideimages.length;i++){ //preload images imageholder[i]=new Image() imageholder[i].src=slideimages[i] } function gotoshow(){ window.location=slidelinks[whichlink] } function slideit(){ if (filtersupport) imgobj.filters[0].apply() imgobj.src=imageholder[whichimage].src if (filtersupport) imgobj.filters[0].play() whichlink=whichimage whichimage=(whichimage<slideimages.length-1)? whichimage+1 : 0 setTimeout("slideit()", slidespeed+blenddelay) } window.onload=function(){ imgobj=document.getElementById("slideshow") //access img obj filtersupport=imgobj.filters //check for support for filters blenddelay=(filtersupport)? imgobj.filters[0].duration*1000 : 0 slideit() } </script> I am not sure if this has been posted before but I need help with this. When a user clicks on the back button I need them to be directed to the previous page and still have their original selections and not the defaults. Here is the rest of code on the back button. At the moment this is not working. <input id=STDBUTSHORT type="button" value="Back" onClick="history.back();">') Thanks in advance. this function seems to be working fine in all browser but of course. I'm still a noob at JavaScript and well things like this just doesn't make sense. when I go to alert this function in IE I get undefined. But other browser gives me a value. What am I doing wrong with this function? Code: function ext() { var img = document.getElementById('photoSmall'); img = img.src; if (typeof img == 'string' && img != 'undefined') { var typeis = img.substr(-4); if (typeis == '.png' || '.jpg' || '.gif') { return typeis; } } } Thanks Jon W I need a back to top link on the bottom of my page that stays there all the time while people are scrolling.. is this possible? is this close to what i'm looking for? http://javascript.internet.com/page-...ting-link.html i've seen it on some other sites but I can't find any to reference now... I'm totally new to this! thanks for your help! -B overview: from my javascript, i call a function in the php block, that function successfully retrieves a value from the database, but when i pass that retrieved value back to the calling function....all is lost somehow. when i test this code by itself, it works fine and gets the correct number. <?php mysql_select_db($database_connFtH, $connFtH); $result = mysql_query("SELECT status_index FROM cpqc_status ORDER BY row_id DESC"); $row_result = mysql_fetch_assoc($result); $index = $row_result['status_index']; echo $row_result['status_index']; echo $index; echo "the value of index is ".$index; ?> however, when i set this same code up as a function to be called upon globally, and to return the value of $index, it all just seems to "not work". <?php function runStatus() { mysql_select_db($database_connFtH, $connFtH); $result = mysql_query("SELECT status_index FROM cpqc_status ORDER BY row_id DESC"); $row_result = mysql_fetch_assoc($result); $index = $row_result['status_index']; return ($index); } //end function runStatus() ?> the calling function, with an alert box to check if the value of $index was passed down accurately <script type="text/javascript"> var x = runStatus(); alert(x); </script> all i want to do is call a server-script function that deals with the database and gets me a value out of the database, and pass that value back to the calling function. can't figure out what is wrong. the "return($index)" should send back the value of $index. the call to that function should receive back a value and assign it to "x". and the alert(x) should spit it out with no problem. but......something is wrong and it won't work. any ideas what is wrong? it is my understanding that a function inside the php determants can be called upon from anywhere and that function can return a value.(?) argh!! i think i know why Einstein's hair was always so messy!! thanks, Paul Williams weather today in Kalispell, MT: 7 deg this morning, got a little snow last night, only about 6 or 8 inches, not much. maybe more later. I am making a simple puzzle game on Android using Phonegap, that is HTML5, CSS3 and JavaScript. When a user fills an answer on a page, if the answer is correct, it will go to another page. However, once the user goes to the next page, he/she CANNOT return back to the previous page. I do not want the user to return back, else he/she will have to fill the answer again to go to the next page, so it's not good. Thank Hello there, I'm a 30yr old returning to school and I signed up for a CMIS102 class, thinking it be more explanatory as the syllabus let on. But I was wrong. While I do understand some of what the professor has been teaching us, like modular programming and IfElse statements, I can't wrap my head around things like While Loops. My professor has saddled us with a couple assignments, requiring us to write in pseudocode and I was wondering if anyone could explain what he wants from this assignment or even help me with it, that maybe I can finally have a grasp of it, and will know what I'm doing on the final. ~Tia P.S. I've posted the assignment question below: I need to write a pseudo-codepseudocode for the following question but don't know how: Write a program to read a list of exam scores (in the range 0 to 100) and to output the total number of grades and the number of grades in each letter=grade category. The end input is indicated by a negative score as a sentinel value. (The negative value is used only to end the loop, so do not use it in the calculations. Example: 88 93 55 77 100 -1 (The output would be) Total number of grades = 5 Number of A's =2 Number of B's = 1 Number of C's =1 Number of D's = 0 Number of F's =1 Must prompt user to run again |