开发者

adding value of input box to URL as a param after a button is pressed?

I ha开发者_如何学Cve 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


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

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

<% end %>


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 ) .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜