Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jonasbn (1153)

  reversethis-{gro.napc} {ta} {nbsanoj}
AOL IM: BJonasN (Add Buddy, Send Message)

Perl Programmer located in Copenhagen, Denmark. Active member of Copenhagen Perl Mongers.

Author of:

  • Business::DK::CPR
  • Business::DK::CVR
  • Business::DK::PO
  • Business::OnlinePayment::CashCow
  • Date::Holidays
  • Date::Holidays::Abstract
  • Date::Holidays::Super
  • Date::Pregnancy
  • Games::Bingo
  • Games::Bingo::Bot
  • Games::Bingo::Print
  • Module::Info::File
  • Module::Template::Setup
  • Test::Timer

and maintainer of:

  • Tie::Tools
  • XML::Conf
  • Workflow

Journal of jonasbn (1153)

Wednesday February 09, 2005
03:37 PM

Firefox JavaScript Weirdness

[ #23105 ]

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
<script type="text/javascript">
    function do_validate () {
        var sum;
        sum = 0;
        if (document.form.box1.value == 'on') {
            alert('box1 = ' + document.form.box1.value);
        if (document.form.box2.value == 'on') {
            alert('box2 = ' + document.form.box2.value);
        if (document.form.box3.value == 'on') {
            alert('box3 = ' + document.form.box3.value);
        if (sum == 0) {
            alert("You have disabled all");
        } else {
            alert(sum + " enabled");
    <?php print_r($_REQUEST); ?>
<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()">

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • 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".

  • It works for me if I change:

        if (document.form.boxn.value == 'on') {
        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 ;)