Hello. I don't know much about Javascript at all, and I need help. The following code works fine in Firefox, but does not work in IE (I've tested it in IE6-8, and all get the same results). The following is the code. Please tell me if you find what's wrong with it. Thanks,
-Stiny
HTML Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en-US"> <head> <title>Distance Between District Buildings</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Cache-Control" content="no-cache" /> <meta http-equiv="expires" content="0" /> </head> <body background="jaa_bgnd.jpg" bgcolor="#ffffee" text="black" link="blue" vlink="#800088" alink="red"> <!-- Page Header --> <center><h1>Distance Between District Buildings</h1></center> <hr /> <!-- Content --> <noscript> <p><img src="error1.png" width="800px"/></p> <p>To run this application, click the bar at the top of the window.</p> <p><img src="error2.png" width="800px"/></p> <p>Then allow the blocked content.</p> </noscript> <script type="text/javascript"> // Hide this code from non-JavaScript browsers CityList=new Array( 'Flint~fnt~dtm=60~lax=1100~sba=9876', 'Detroit~dtm~fnt=61~lax=1500~sba=1', 'Los Angeles~lax~fnt=1101~dtm=1599~sba=666', 'StrongBadia~sba~fnt=9876~dtm=1~lax=666' ); Out =''; Out+=' <br \/>\n'; Out+=' <center>\n'; Out+=' <form method="post" action="" onsubmit="return GetDistance()">\n'; Out+=' From: \n'; Out+=' <select name="GoFrom" id="GoFrom">\n'; document.write(Out); for (ix1=0; ix1<CityList.length; ix1++) { CL_line=CityList[ix1]; CL_items=CL_line.split(/~/); Out =''; Out+=' <option value="'+CL_items[1]+'">'+CL_items[0]+'<\/option\n'; document.write(Out); } Out =''; Out+=' <\/select>\n'; Out+=' To: \n'; Out+=' <select name="GoTo" id="GoTo">\n'; document.write(Out); for (ix1=0; ix1<CityList.length; ix1++) { CL_line=CityList[ix1]; CL_items=CL_line.split(/~/); Out =''; Out+=' <option value="'+CL_items[1]+'">'+CL_items[0]+'<\/option\n'; document.write(Out); } Out ='' Out+=' <\/select>\n'; Out+=' <br \/><br \/>\n'; Out+=' <input type="submit" value=" Submit " title=" Submit " \/> \n'; Out+=' <input type="reset" value=" Reset " title=" Reset " \/>\n'; Out+=' <br \/><br \/>\n'; Out+=' Distance: \n'; Out+=' <input type="text" name="result" id="result" \/>\n'; Out+=' </form>\n'; Out+=' </center>\n'; document.write(Out); function GetDistance() { f1=document.forms[0]; // abbreviation FI=f1.GoFrom.selectedIndex; // the 'from' index FV=f1.GoFrom.options[FI].value; // ...code FT=f1.GoFrom.options[FI].text; // ...text TI=f1.GoTo.selectedIndex; // the 'to' index TV=f1.GoTo.options[TI].value; TT=f1.GoTo.options[TI].text; if (FV == TV) { // short trip! f1.result.value=0; return false; } CL_line=CityList[FI]; CL_items=CL_line.split(/~/); for (ix1=2; ix1<CL_items.length; ix1++) { CL_item=CL_items[ix1]; ix2=CL_item.indexOf('='); Code=CL_item.substring(0,ix2); Distance=CL_item.substring(ix2+1); if (Code == TV) { f1.result.value=Distance; return false; } } f1.result.value=FT+' to '+TT+' not found.'; return false; } // End hiding --> </script> <!-- Page Footer --> <br clear="all" /><hr /> Written on July 27, 2009 </body> </html>



Reply With Quote
Bookmarks