Help with passing user's input to remote_function

<%= form_tag( “http://search2.library.oregonstate.edu/record/search”)
%>
<%= text_field_tag(‘query’,value=“Enter keywords”,{ :size=>
“35”, :accesskey=> “s”}) %>
<%= hidden_field_tag(‘tab’, value=“general”)%>
<%= hidden_field_tag(‘group’, value=“g5”)%>
<%= submit_tag ‘Go’, :onclick =>remote_function(:url =>
{:action => :store_query, :id => @mod, :page => @page, :query
=> ??? } ) %>
<%= end_form_tag %>

In the remote_function call I want to pass the text_field named
‘query’ value as a param, so, :query => ???
How do I get the value out of the text field and into my param hash?

Everything else works, and I can put a static value in the query hash
and get the functionality I am looking for. But, how to get the user’s
input???

Thanks in advance, K

Hi,

Can you make the form itself an AJAX form by using <%= form_remote_tag
…%> your view may look something like:

<%= form_remote_tag :url=>{:action=>store_query} %>
<%= text_field_tag(‘query’,value=“Enter keywords”,{ :size=>“35”,
accesskey=>“s”}) %>
<%= hidden_field_tag(‘tab’, value=“general”)%>
<%= hidden_field_tag(‘group’, value=“g5”)%>
<%= hidden_field_tag(‘id’, value=>@mod)%>
<%= hidden_field_tag(‘page’, value=>@page)%>
<%= submit_tag ‘Go’ %>
<% end_form_tag %>

Hope this helps!

Shawn

Kim wrote:

<%= form_tag( “http://search2.library.oregonstate.edu/record/search”)
%>
<%= text_field_tag(‘query’,value=“Enter keywords”,{ :size=>
“35”, :accesskey=> “s”}) %>
<%= hidden_field_tag(‘tab’, value=“general”)%>
<%= hidden_field_tag(‘group’, value=“g5”)%>
<%= submit_tag ‘Go’, :onclick =>remote_function(:url =>
{:action => :store_query, :id => @mod, :page => @page, :query
=> ??? } ) %>
<%= end_form_tag %>

In the remote_function call I want to pass the text_field named
‘query’ value as a param, so, :query => ???
How do I get the value out of the text field and into my param hash?

Everything else works, and I can put a static value in the query hash
and get the functionality I am looking for. But, how to get the user’s
input???

Thanks in advance, K

No - I am calling two actions - the form action to the search tool which
is
another RoR project and the remote function call which is an action in
this
project. I have it working anyways - I used :with and prototype’s $F()

The solution:
:onclick =>remote_function(:url => {:action => :store_query, :id =>
@mod,
:page => @page}, :with => “‘query=’+$F(‘query’)” )

On 3/21/07, Shware [email protected] wrote:

<%= hidden_field_tag('tab', value="general")%>
<%= end_form_tag %>


Posted via http://www.ruby-forum.com/.


Kim G.
[email protected]

“We are all stakeholders in the Karma economy.”