HighDots Forums  

Firefox bug?

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Firefox bug? in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rippo
 
Posts: n/a

Default Firefox bug? - 09-09-2005 , 07:30 AM






I have the following HTML code

<input value="1" type="checkbox" name="A1"
onClick="tickOff(Array('A2','A3'));"/><br/>

<input value="1" type="checkbox" name="A2"
onClick="tickOff(Array('A1','A3'));"/><br/>

<input value="1" type="checkbox" name="A2"
onClick="tickOff(Array('A1','A2'));"/><br/>

and the follwing jscript

<script language="javascript">
function tickOff(inA){
for (var i=0;i<inA.length;i++) {
var m = document.getElementById(inA[i]);
m.checked = false;
}
}
</script>

All works well in IE but i get an error if I use firefox! Can anyone
help me.
Many thanks


Reply With Quote
  #2  
Old   
Kimmo Laine
 
Posts: n/a

Default Re: Firefox bug? - 09-09-2005 , 07:45 AM






"Rippo" <info (AT) rippo (DOT) co.uk> wrote

Quote:
I have the following HTML code

input value="1" type="checkbox" name="A1"
onClick="tickOff(Array('A2','A3'));"/><br/

input value="1" type="checkbox" name="A2"
onClick="tickOff(Array('A1','A3'));"/><br/

input value="1" type="checkbox" name="A2"
onClick="tickOff(Array('A1','A2'));"/><br/

and the follwing jscript

script language="javascript"
function tickOff(inA){
for (var i=0;i<inA.length;i++) {
var m = document.getElementById(inA[i]);
m.checked = false;
}
}
/script

All works well in IE but i get an error if I use firefox! Can anyone
help me.
Many thanks

It works in IE because it's wrong. IE thinks it's polite to present
correctly things that were done wrong. You have not defined id's for the
inputs, yet you use getElementById. IE uses names instead of id's, if no
id's were found. This is quite stupid IMHO, since it lead's to zillions of
errors, since not all browsers - including Firefox - are that
error-tolerant. To fix it, give id's to the inputs as well as names. You'll
just have one problem: id's must be unique. You cannot have two fields with
same id...

Also: I think this should have the keyword 'new':
onClick="tickOff(Array('A1','A2'));"

so it would be
onClick="tickOff(new Array('A1','A2'));"

but I'm not 100% sure about this.

The major problem however is not a bug in Firefox, instead it's a "feature"
(a bug) in IE.

--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com




Reply With Quote
  #3  
Old   
Rippo
 
Posts: n/a

Default Re: Firefox bug? - 09-09-2005 , 08:29 AM



Thanks very much Kimmo. I cant believe I did not have the ID in!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.