# Help with passing user's input to remote\_function

**URL:** <https://www.ruby-forum.com/t/help-with-passing-users-input-to-remote-function/89632>\
**Category:** Rails\
**Created:** [March 21, 2007, 6:19pm UTC](https://www.ruby-forum.com/t/help-with-passing-users-input-to-remote-function/89632 "2007-03-21T18:19:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kim](https://www.ruby-forum.com/u/kim)\
**Post date:** [March 21, 2007, 6:19pm UTC](https://www.ruby-forum.com/t/help-with-passing-users-input-to-remote-function/89632/1 "2007-03-21T18:19:01Z")

</div>

\<%= form\_tag( “[http://search2.library.oregonstate.edu/record/search](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

---

<div class="post-metadata">

**Author:** ![kim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kim](https://www.ruby-forum.com/u/kim)\
**Post date:** [March 21, 2007, 7:57pm UTC](https://www.ruby-forum.com/t/help-with-passing-users-input-to-remote-function/89632/2 "2007-03-21T19:57:59Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![kim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kim](https://www.ruby-forum.com/u/kim)\
**Post date:** [March 21, 2007, 8:23pm UTC](https://www.ruby-forum.com/t/help-with-passing-users-input-to-remote-function/89632/3 "2007-03-21T20:23:26Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> <%= hidden_field_tag('tab', value="general")%>
> 
> ```
> 
> > ```
> > <%= end_form_tag %>
> > 
> > ```
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Kim G.  
removed\_email\_address@domain.invalid

“We are all stakeholders in the Karma economy.”
