Michel Dogger
2006-Jun-07 12:44 UTC
[Rails] check_box:how to update 2 checkboxes dependent on each other
I''ve got the following problem, I''ve created two check_boxes in my view. The user has to select one check_box, but isn''t allowed to seth both of them together on true. Now i am looking for functionality that can help me doing the folling: Scenario 1 CheckBox1 = True, The user sets CheckBox2 from False to True, now CheckBox1 should automatically become False. Scenario 2 CheckBox2 = True, The user sets CheckBox1 from False to True, now CheckBox2 should automatically become False. Is there somebody, who knows how to build a function for that? The select_boxes in my view look like this: <%= check_box ''account'', ''agriculture'' %> <%= check_box ''account'', ''vat_duty'' %> -> agriculture and var_duty are both existing fields in my model. Thnx Michel Dogger -- Posted via http://www.ruby-forum.com/.
Daniel N
2006-Jun-07 13:47 UTC
[Rails] check_box:how to update 2 checkboxes dependent on each other
Try radio buttons. These only allow one selection at a time On 6/7/06, Michel Dogger <micheldogger@gmail.com> wrote:> > I''ve got the following problem, > > I''ve created two check_boxes in my view. The user has to select one > check_box, > but isn''t allowed to seth both of them together on true. Now i am > looking for functionality that can help me doing the folling: > > Scenario 1 > CheckBox1 = True, The user sets CheckBox2 from False to True, now > CheckBox1 should automatically become False. > > Scenario 2 > CheckBox2 = True, The user sets CheckBox1 from False to True, now > CheckBox2 should automatically become False. > > Is there somebody, who knows how to build a function for that? > > > The select_boxes in my view look like this: > > <%= check_box ''account'', ''agriculture'' %> > <%= check_box ''account'', ''vat_duty'' %> > > -> agriculture and var_duty are both existing fields in my model. > > Thnx Michel Dogger > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060607/811ffc42/attachment-0001.html
Brian Hogan
2006-Jun-07 13:57 UTC
[Rails] check_box:how to update 2 checkboxes dependent on each other
Almost sounds like radio buttons, or am I not understanding your question? True ( ) False ( ) On 6/7/06, Michel Dogger <micheldogger@gmail.com> wrote:> I''ve got the following problem, > > I''ve created two check_boxes in my view. The user has to select one > check_box, > but isn''t allowed to seth both of them together on true. Now i am > looking for functionality that can help me doing the folling: > > Scenario 1 > CheckBox1 = True, The user sets CheckBox2 from False to True, now > CheckBox1 should automatically become False. > > Scenario 2 > CheckBox2 = True, The user sets CheckBox1 from False to True, now > CheckBox2 should automatically become False. > > Is there somebody, who knows how to build a function for that? > > > The select_boxes in my view look like this: > > <%= check_box ''account'', ''agriculture'' %> > <%= check_box ''account'', ''vat_duty'' %> > > -> agriculture and var_duty are both existing fields in my model. > > Thnx Michel Dogger > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Brian Hogan
2006-Jun-07 14:00 UTC
[Rails] check_box:how to update 2 checkboxes dependent on each other
Nevermind.... I get it... they''re two separate options. You''re describing something typically done with Javascript. onclick functions on each button would modify the other button. THere are things like observe_field and other helpers in Rails that are available for this, but it might be pretty easy to do it yourself. On 6/7/06, Brian Hogan <bphogan@gmail.com> wrote:> Almost sounds like radio buttons, or am I not understanding your question? > > True ( ) False ( ) > > > On 6/7/06, Michel Dogger <micheldogger@gmail.com> wrote: > > I''ve got the following problem, > > > > I''ve created two check_boxes in my view. The user has to select one > > check_box, > > but isn''t allowed to seth both of them together on true. Now i am > > looking for functionality that can help me doing the folling: > > > > Scenario 1 > > CheckBox1 = True, The user sets CheckBox2 from False to True, now > > CheckBox1 should automatically become False. > > > > Scenario 2 > > CheckBox2 = True, The user sets CheckBox1 from False to True, now > > CheckBox2 should automatically become False. > > > > Is there somebody, who knows how to build a function for that? > > > > > > The select_boxes in my view look like this: > > > > <%= check_box ''account'', ''agriculture'' %> > > <%= check_box ''account'', ''vat_duty'' %> > > > > -> agriculture and var_duty are both existing fields in my model. > > > > Thnx Michel Dogger > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Chris Kampmeier
2006-Jun-07 14:45 UTC
[Rails] Re: check_box:how to update 2 checkboxes dependent on each o
Still, it sounds like you should use radio buttons. It''ll be more accessible that way--this is what radio buttons were designed for. Then, take care of the different variables in your model at the application level. Perhaps with a before_save in your model? -- Posted via http://www.ruby-forum.com/.