# Set Value of text\_field after onchange

**URL:** <https://www.ruby-forum.com/t/set-value-of-text-field-after-onchange/148250>\
**Category:** Rails\
**Created:** [September 10, 2008, 10:49pm UTC](https://www.ruby-forum.com/t/set-value-of-text-field-after-onchange/148250 "2008-09-10T22:49:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pat](https://www.ruby-forum.com/u/pat)\
**Post date:** [September 10, 2008, 10:49pm UTC](https://www.ruby-forum.com/t/set-value-of-text-field-after-onchange/148250/1 "2008-09-10T22:49:36Z")

</div>

Hi,

I have a text field which is :

\<%= text\_field( “select”, “name” ,{:onchange =\>  
“this.form.submit();”} ) %\>

I want to search database using value entered by user, and when search  
results are displayed, I want to have text field retailn the value  
which was entered to have search results.

I did something like this,

\<% eventname = params[:select\_name]%\>  
\<%if eventname!=nil%\>  
\<% @select.name = eventname %\>  
\<% end %\>

Still, it does not contain that value which user entered.

Can anyone help please?

Thanks very much,  
Pat

---

<div class="post-metadata">

**Author:** ![pat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@pat](https://www.ruby-forum.com/u/pat)\
**Post date:** [September 10, 2008, 10:57pm UTC](https://www.ruby-forum.com/t/set-value-of-text-field-after-onchange/148250/2 "2008-09-10T22:57:48Z")

</div>

On Sep 10, 6:34 pm, Pat [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

Take a look at development.log (or if you’ve just done ruby script/  
server, the output will be in that window too). The log shows you the  
params hash for each request. You should be able to work it out from  
there.

Fred
