I have this JS code to calculate some points, under FireFox forks great but with IE I get an error: The same code works fine (firefox + IE) if he's on a separate page see http://ethereals.bynetics.net/arena.html Any suggestions? PS: IE v7.0.5730.11 FireFox v2.0.06 <SCRIPT LANGUAGE="JavaScript"> var ap var t var r function testButton (form){ for (Count = 0; Count < 3; Count++) { if (form.rad[Count].checked) break; } t = form.rad[Count].value r = form.rating.value if (r>1500) { ap = 1426.79 /(1+918.836*Math.pow(2.71828,(-0.00386405*r)));} else { ap = 0.38*r-194;} if (t==2) {ap= Math.floor(0.7*ap);} if (t==3) {ap= Math.floor(0.8*ap);} if (t==5) {ap= Math.floor(ap);} if (ap<=0) {ap=0;} alert("Your " + t + "v" + t + " team gets for " + r + " rating\n" + ap + " Arena Points"); } </SCRIPT> </BODY> <FORM NAME="testform"> <INPUT type="text" NAME="rating" size="4" value="1500"/><BR> <table width="40" border="0"> <tr> <td><INPUT TYPE="radio" NAME="rad" Value="2" onClick=0 checked> 2v2</td> <td><INPUT TYPE="radio" NAME="rad" Value="3" onClick=0> 3v3</td> <td><INPUT TYPE="radio" NAME="rad" Value="5" onClick=0> 5v5 </td> </tr> </table> <BR> <INPUT TYPE="button" NAME="button" Value="Calculate" onClick="testButton(this.form)"> <BR> </FORM> PHP:
I used Microsoft Script Editor, and the Error is on this line: for (Count = 0; Count < 3; Count++) { HERE--> if (form.rad[Count].checked) break; } PHP:
no ideas, something else wrong in the page? Help pls... page looks unfinished with: "Works with Firefox only"...
It is curious - I've noticed that sometimes IE has a stricter JavaScript engine than Firefox. Can you post a link to the page where the error is occuring?
hi, just come back from a vacation... so I tried the replacement and it was ok, to 1 point :| when i tried to replace the next form. It is correct to replace: for (Count = 0; Count < 3; Count++) { if (form.rad[Count].checked) break; } t = form.rad[Count].value r = form.rating.value PHP: with for (Count = 0; Count < 3; Count++) { if (document.getElementsByName('rad')[Count].checked) break; } t = document.getElementsByName('rad')[Count].value r = document.getElementsByName('rating').value PHP: the script works but i get: "Your 2v2 team gets for undefined rating NaN Arena Points" seams that the "t" and "r" aren't correct
/up pls can someone look at this again, my Firefox was blocked recently and the script dosn't run uder IE
this is really funny, hehe. It doesn't work in ie because you don't close the <center> tag. i.e.: <center <form... which doesn't put it in the dom tree for ie. I closed the <center> tag and it worked. an excellent example of why you should validate with the W3 validator.
Oh my god I still cant belive that this was the reason ... Still mozilla seams to be better - it worked without the tag closed. Ty all.