views:

18

answers:

2

Hi

I have one input field and 2 buttons, each button performs a different function. i want one of the buttons to take the value of the input field and add it to a specified Url (as a param) that button should go to.

so if the value inserted in to the box is "dog" then after clicking the button the URL should be "/go_somwhere?value=dog"

can i do it in just html or do i need a ruby method?

i'm using rails.

thanks

+1  A: 

Seems like you would need to do this via javascript on the client side . The button should have a function attached to its click event . This function should read the value from the input box and change the url ( window.locations ) .

NM
+2  A: 
<% form_for :item, :url=>{:action=>'go_somwhere'}, :html => { :method=>"get"} do|f| %>

<%= text_field_tag :value, "" %>
<input type="submit" value="Submit" >

<% end %>
Salil
Will this work if its in a '<form>' tag?
Mo
It will work if its in a form tag. You can access that value from controller's action as `param[:value]`. Your other button that you mentioned should be outside the `form_for` block
Shripad K