# Pass two values when checkbox is checked

**URL:** <https://www.ruby-forum.com/t/pass-two-values-when-checkbox-is-checked/129300>\
**Category:** Rails\
**Created:** [February 16, 2008, 11:52am UTC](https://www.ruby-forum.com/t/pass-two-values-when-checkbox-is-checked/129300 "2008-02-16T11:52:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![warlock\_handler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/57b2e6/32.png) [@warlock\_handler](https://www.ruby-forum.com/u/warlock_handler)\
**Post date:** [February 16, 2008, 11:52am UTC](https://www.ruby-forum.com/t/pass-two-values-when-checkbox-is-checked/129300/1 "2008-02-16T11:52:20Z")

</div>

Hi  
I want to pass two set of values when a particular check box is checked

for eg.  
If I have name and email address.  
how should I write the view code  
if in my controller I want the name and email address accessible from my  
params hash…

regards,  
warlock

---

<div class="post-metadata">

**Author:** ![warlock\_handler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/57b2e6/32.png) [@warlock\_handler](https://www.ruby-forum.com/u/warlock_handler)\
**Post date:** [February 16, 2008, 1:43pm UTC](https://www.ruby-forum.com/t/pass-two-values-when-checkbox-is-checked/129300/2 "2008-02-16T13:43:03Z")

</div>

Vinay B. wrote:

> Hi  
> I want to pass two set of values when a particular check box is checked

h\> for eg.

> If I have name and email address.  
> how should I write the view code  
> if in my controller I want the name and email address accessible from my  
> params hash…
> 
> regards,  
> warlock

not sure about the specifics of a check box but you can just extra  
params after you for eg your action/controller.

for example:

\<%= link\_to\_remote “Link name”, :url=\>{:controller=\> “profile”,  
:action=\>“index”, :email=\>@email,:name=\>@name}%\>

then in your controller you can access the @email and @name as params

def index  
@email = params[:email]  
@name = params[:name]  
end

i’ve never used a checkbox in this way but I think this is the general  
idea. hope it helps.

---

<div class="post-metadata">

**Author:** ![warlock\_handler](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/57b2e6/32.png) [@warlock\_handler](https://www.ruby-forum.com/u/warlock_handler)\
**Post date:** [February 17, 2008, 12:32pm UTC](https://www.ruby-forum.com/t/pass-two-values-when-checkbox-is-checked/129300/3 "2008-02-17T12:32:12Z")

</div>

ohhhh ok … got it… i will try some RnD on this… will reply if i get  
any other better way to do this…

Phil T. wrote:

> not sure about the specifics of a check box but you can just extra  
> params after you for eg your action/controller.
> 
> for example:
> 
> \<%= link\_to\_remote “Link name”, :url=\>{:controller=\> “profile”,  
> :action=\>“index”, :email=\>@email,:name=\>@name}%\>
> 
> then in your controller you can access the @email and @name as params
> 
> def index  
> @email = params[:email]  
> @name = params[:name]  
> end
> 
> i’ve never used a checkbox in this way but I think this is the general  
> idea. hope it helps.
