Author of:
and maintainer of:
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
<?php
// Firefox test
?>
<html>
<head>
<script type="text/javascript">
function do_validate () {
var sum;
sum = 0;
if (document.form.box1.value == 'on') {
alert('box1 = ' + document.form.box1.value);
sum++;
}
if (document.form.box2.value == 'on') {
alert('box2 = ' + document.form.box2.value);
sum++;
}
if (document.form.box3.value == 'on') {
alert('box3 = ' + document.form.box3.value);
sum++;
}
if (sum == 0) {
alert("You have disabled all");
} else {
alert(sum + " enabled");
}
document.form.submit();
}
</script>
</head>
<body>
<pre>
<?php print_r($_REQUEST); ?>
</pre>
<form method="POST" action="<?=$_SERVER['PHP_SELF']?>" name="form">
<input type="checkbox" name="box1" <?= ($_REQUEST['box1'])?"CHECKED":"";?>>
<input type="checkbox" name="box2" <?= ($_REQUEST['box2'])?"CHECKED":"";?>>
<input type="checkbox" name="box3" <?= ($_REQUEST['box3'])?"CHECKED":"";?>>
<input type="button" value="submit" onClick="do_validate()">
</form>
</body>
</html>
Wrong property (Score:2)
For this snippet, document.form.box2.value will be "yes".
Re:Wrong property (Score:2)
Maybe I should get myself a JavaScript desktop reference
jonasbn
checked? (Score:1)
It works for me if I change:
to: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 ;)
--simonflk
Re:checked? (Score:2)
jonasbn