On Fri, 2009-07-10 at 23:51 +0200, Massimo Lombardo wrote: > Please, using plain English only, explain what you want to do. > Then we'll try to help ;)
Alright. > 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? Having two DOM elements with the same name attribute is still valid (see <input type="radio">.) My main question is how does both the 'if' block and the 'else' block get executed in the same pass through the function? > 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. That is it. That way only one of the two inputs of name="billable" get sent to the handler on the server. This page is a RT (request tracker) module and RT handles the processing of the (server-side.) I would rather not modify the RT codebase to handle the checkbox - I thought it could be done via JS. My main questions still stands, how does both the 'if' and 'else' blocks get executed on the same pass through the function? Thanks for the time and help. Cheers, > 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 > > > > > -- 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
signature.asc
Description: This is a digitally signed message part