# How to workout with option buttons

**URL:** <https://www.ruby-forum.com/t/how-to-workout-with-option-buttons/143730>\
**Category:** Rails\
**Created:** [July 22, 2008, 10:04am UTC](https://www.ruby-forum.com/t/how-to-workout-with-option-buttons/143730 "2008-07-22T10:04:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hema\_mca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@hema\_mca](https://www.ruby-forum.com/u/hema_mca)\
**Post date:** [July 22, 2008, 10:04am UTC](https://www.ruby-forum.com/t/how-to-workout-with-option-buttons/143730/1 "2008-07-22T10:04:05Z")

</div>

I need a form development with the following requirements…

I have the employee form he has a dependent or may not so i took the  
option buttons yes/no based on that the data to be stored in the  
database either ‘y’/‘n’.  
i wrote the java script event for the onclick event of the buttons(YES  
and NO)  
in that i am not getting how to set the field to the @employee.dependent  
in the controller if i do @employee.dependent=‘y’ it is working fine  
before the @employee.save

i need that action according to the option buttons in the \_form.rhtml…  
i tried by creating the class variable @depend it is declared in my  
model in the employee class and is accessed form the .rhtml \<%=  
@employee.depend=‘y’ %\>  
but it is not working…

or even i tried with the instance variable @depend in my controller and  
in the .rhtml i tried as \<%= @depend=‘y’ %\>  
i wrote the line @employee.dependent = @depend before the statement  
@employee.save  
even it is also not working can anyone help me regarding this…
