Please, using plain English only, explain what you want to do.
Then we'll try to help ;)

The glitch is probably caused by the fact that the two input fields
*do* share the same name; then when you touch one, you *do* alter
both! Bug or feature?

As far as I got it, (and pretending that I got it right) you're trying
to enable/disable an hidden input field based on another checkbox's
checked state.
If so, you're running insanely fast by the wrong side of the street...

So: give us some hint :)

On Fri, Jul 10, 2009 at 22:38, Matt Zagrabelny<mzagr...@d.umn.edu> wrote:
> Greetings,
>
> I am experiencing some crazy stuff, at least crazy to me...
>
> Both the 'if' and 'else' blocks (according to firebug) are being
> executed in the following anonymous function:
>
> <html>
> <head>
> <script language="javascript" type="text/javascript"
> src="/usr/share/javascript/jquery/jquery.js"></script>
> <script language="javascript" type="text/javascript">
> $(function() {
>  add_billable_oncheck();
> });
>
> function add_billable_oncheck() {
>  var billable_hidden   = $('#billable_hidden')[0];
>  var billable_checkbox = $('#billable_checkbox')[0];
>  if ((billable_hidden   != null) &&
>      (billable_checkbox != null)) {
>    $(billable_checkbox).change(
>      function(event) {
>
> // These are the blocks that both get executed on checkbox check
>        if (billable_checkbox.checked) {
>          billable_hidden.disabled = true;
>        } else {
>          billable_hidden.disabled = false;
>        }
> // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>      }
>    );
>  }
> }
> </script>
> </head>
> <body>
> <form>
>  <input id="billable_hidden" type="hidden" name="billable"
> value="No" />
>  <input id="billable_checkbox" type="checkbox" name="billable"
> value="Yes" />
> </form>
> </body>
> </html>
>
> Does anyone have any insight into this one?
>
> If I add 'return;' statements at the end of the blocks, things work as
> expected, however I wouldn't expect that I should have to do that.
>
> Thanks for the help,
>
> --
> Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844
> University of Minnesota Duluth
> Information Technology Systems & Services
> PGP key 1024D/84E22DA2 2005-11-07
> Fingerprint: 78F9 18B3 EF58 56F5 FC85  C5CA 53E7 887F 84E2 2DA2
>
> He is not a fool who gives up what he cannot keep to gain what he cannot
> lose.
> -Jim Elliot
>



-- 
Linux user #437712

Reply via email to