Code: <%= check_box("schedule_report", "active_#{id}", options={:id=>"schedule_report_#{id}_active", :checked =>schedule_report.active }, 1, 0) %> Rendered output: <input type="hidden" value="0" name="schedule_report[active_20]"> <input id="schedule_report_20_active" type="checkbox" value="1" name="schedule_report[active_20]" checked="checked"> <input type="hidden" value="0" name="schedule_report[active_17]"> <input id="schedule_report_17_active" type="checkbox" value="1" name="schedule_report[active_17]"> ....... Problem: The value of "1" is always passed, even if the box is UNCHECKED. Please help! Thanks! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Go read a basic html tutorial, concentrating on the syntax of an <input> tag. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, Sep 11, 2011 at 23:37, Joan Gu <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Code: > <%= check_box("schedule_report", "active_#{id}", > options={:id=>"schedule_report_#{id}_active", :checked > =>schedule_report.active }, 1, 0) %> > > Rendered output: > <input type="hidden" value="0" name="schedule_report[active_20]"> > <input id="schedule_report_20_active" type="checkbox" value="1" > name="schedule_report[active_20]" checked="checked"> > > <input type="hidden" value="0" name="schedule_report[active_17]"> > <input id="schedule_report_17_active" type="checkbox" value="1" > name="schedule_report[active_17]"> > ....... > > Problem: > The value of "1" is always passed, even if the box is UNCHECKED. > Please help!Passed to your browser as evidenced by the above renderings (which would be correct), or as in, the form always returns a 1? Big difference. In the latter case, we''d need to know what browser (and possibly OS), unless you mean all. Could be just a browser bug. -Dave -- Main Web Site: davearonson.com | LOOKING FOR WORK, Programming Blog: codosaur.us | preferably RoR, in NoVa/DC; Excellence Blog: dare2xl.com | see main web site. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dave Aronson wrote in post #1021425:> On Sun, Sep 11, 2011 at 23:37, Joan Gu <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> <input type="hidden" value="0" name="schedule_report[active_17]"> >> <input id="schedule_report_17_active" type="checkbox" value="1" >> name="schedule_report[active_17]"> >> ....... >> >> Problem: >> The value of "1" is always passed, even if the box is UNCHECKED. >> Please help! > > Passed to your browser as evidenced by the above renderings (which > would be correct)I also suggest that you go read a beginning html tutorial. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mon, Sep 12, 2011 at 09:59, 7stud -- <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I also suggest that you go read a beginning html tutorial.Howzabout, rather than just getting all snarky, you point out to Joan and me, what''s going wrong? MINSWAN, remember? -Dave -- Main Web Site: davearonson.com | LOOKING FOR WORK, Programming Blog: codosaur.us | preferably RoR, in NoVa/DC; Excellence Blog: dare2xl.com | see main web site. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 12, 4:37 am, Joan Gu <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Code: > <%= check_box("schedule_report", "active_#{id}", > options={:id=>"schedule_report_#{id}_active", :checked > =>schedule_report.active }, 1, 0) %> > > Rendered output: > <input type="hidden" value="0" name="schedule_report[active_20]"> > <input id="schedule_report_20_active" type="checkbox" value="1" > name="schedule_report[active_20]" checked="checked"> > > <input type="hidden" value="0" name="schedule_report[active_17]"> > <input id="schedule_report_17_active" type="checkbox" value="1" > name="schedule_report[active_17]"> > ....... > > Problem: > The value of "1" is always passed, even if the box is UNCHECKED. > Please help! >So what does the code calling this look like (i.e. what collection are you iterating over) ? What do the received params look like ? Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 12 September 2011 15:13, Dave Aronson <googlegroups2dave-BRiZGj7G2yRXqviUI+FSNg@public.gmane.org> wrote:> On Mon, Sep 12, 2011 at 09:59, 7stud -- <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> I also suggest that you go read a beginning html tutorial. > > Howzabout, rather than just getting all snarky, you point out to Joan > and me, what''s going wrong? MINSWAN, remember?+1 I''ve been wracking my brains to see what''s wrong with the HTML (especially since it''s been generated with the check_box() helper). Maybe I''m missing something obvious... ? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 12 Sep 2011, at 20:11, Michael Pavling wrote:> I''ve been wracking my brains to see what''s wrong with the HTML > (especially since it''s been generated with the check_box() helper). > Maybe I''m missing something obvious... ?I don''t think you''re missing anything -- I''ve tested Joan''s code in Safari and it works as expected (you find ''0'' in the params when you uncheck a box). I do seem to remember some weirdness with Rails'' checkboxes/hidden fields pairs and Firefox, to do with the way it restores form state when you go back to (or even reload) a form. However, I couldn''t replicate the problem in Firefox 6.0.1, so maybe it''s an old bug or maybe I''m misremembering things. Joan, are you testing in Firefox by any chance? Chris -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you all for the help. Yes, the test was done in firefox 6.0.2 and the params were passed through an ajax link by checking checkbox value (jquery). Can''t paste the code here coz I can''t access the source now. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 13, 3:39 pm, Joan Gu <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Thank you all for the help. > > Yes, the test was done in firefox 6.0.2 and the params were passed > through an ajax link by checking checkbox value (jquery). Can''t paste > the code here coz I can''t access the source now. >Ah, ajax may be the key. How are you serialising the form inputs? If you''re always submitting the checkbox''s value then it will indeed only ever submit ''1''. You''d need to select the appropriate value based on whether the checkbox was checked. Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote in post #1021765:> Ah, ajax may be the key. How are you serialising the form inputs? If > you''re always submitting the checkbox''s value then it will indeed only > ever submit ''1''. You''d need to select the appropriate value based on > whether the checkbox was checked. > > FredHi Fred, Yes, you are right, the ajax code passing checkbox''s value is the root cause. Problem fixed and thanks for help. Joan -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.