Firefox JavaScript Weirdness

jonasbn on 2005-02-09T20:37:41

I normally use the Safari browser, but I have grown quite fond of the Fixefox browser for JavaScript debugging. But I ran into a weird problem today - a in Safari working Javascript acts really weird in Firefox - or maybe it is just me?

Try this out in Firefox and try disabling all checkboxes


// Firefox test

?>

	
> > >


Wrong property

bart on 2005-02-09T21:42:32

You should be checking document.form.box1.checked, not document.form.box1.value. The latter is the value attribute, the value that the checkbox would use to submit, when checked. It's the same attribute as in HTML:
<input type="checkbox" name="box2" value="yes">

For this snippet, document.form.box2.value will be "yes".

Re:Wrong property

jonasbn on 2005-02-10T19:59:08

Thanks :)

Maybe I should get myself a JavaScript desktop reference

jonasbn

checked?

simonflk on 2005-02-09T21:50:32

It works for me if I change:

    if (document.form.boxn.value == 'on') {
to:
    if (document.form.boxn.checked) {
As to whether this is appropriate behaviour, I have no idea.

Btw, I had to remove all those <? ?>. They were giving me all kinds of odd errors ;)

Re:checked?

jonasbn on 2005-02-10T20:01:19

Well I guess it working in Safari confused me, thanks for the response and sorry about the :)

jonasbn