# Access input field id inside erb code

**URL:** <https://www.ruby-forum.com/t/access-input-field-id-inside-erb-code/112879>\
**Category:** Rails\
**Created:** [August 24, 2007, 2:11am UTC](https://www.ruby-forum.com/t/access-input-field-id-inside-erb-code/112879 "2007-08-24T02:11:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![memius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/db5fbb/32.png) [@memius](https://www.ruby-forum.com/u/memius)\
**Post date:** [August 24, 2007, 2:11am UTC](https://www.ruby-forum.com/t/access-input-field-id-inside-erb-code/112879/1 "2007-08-24T02:11:35Z")

</div>

This is the simplified code :

\<%= link\_to ’ Search ', :action =\> ‘show\_activity’, :name =\> ???%\>

I would like to pass the name as a parameter to my action. The name  
should be the value of the input field with id ‘activity\_lookup’.  
I did not find a solution on how to do this :s  
include javascript ? javascipt\_tag ? (tried this, but did not do the job  
… )

As you will guess : I am using this bit of code for an auto complete  
field (example from the rails recipes book)

Is there a nice way to do this ?  
Am I looking in the wrong direction and is it much easier ?

Thx for your help.

---

<div class="post-metadata">

**Author:** ![memius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/db5fbb/32.png) [@memius](https://www.ruby-forum.com/u/memius)\
**Post date:** [August 24, 2007, 7:02am UTC](https://www.ruby-forum.com/t/access-input-field-id-inside-erb-code/112879/2 "2007-08-24T07:02:42Z")

</div>

Hi Dieter,

this is working for me:

\<%= link\_to ‘Search’, {:action =\> ‘show\_activity’, :name =\> ‘Dieter’ }  
%\>

Note: Check how to pass arguments to “link\_to” in  
[http://api.rubyonrails.org/](http://api.rubyonrails.org/)  
In your case it’s take name as the html\_options so it will rendered as  
an attribute of tag like this

[ 

I guess this answers your question.

 

On Aug 24, 5:11 am, Dieter D’haeyere \<rails-mailing-l…@andreas-

](http://example.com/controller/some_action)

---

<div class="post-metadata">

**Author:** ![memius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/db5fbb/32.png) [@memius](https://www.ruby-forum.com/u/memius)\
**Post date:** [August 24, 2007, 8:48am UTC](https://www.ruby-forum.com/t/access-input-field-id-inside-erb-code/112879/3 "2007-08-24T08:48:39Z")

</div>

> \<%= link\_to ‘Search’, {:action =\> ‘show\_activity’, :name =\> ‘Dieter’ }  
> %\>

this was not what I meant.  
I want to pass the value of the input field with id “activity\_lookup”  
Whay you are saying is something very static.

I was thinking in the direction of :  
:name =\> javascript\_tag(‘document.elementById(“activity\_lookup”).value’)

But that doesn’t work.

The ‘name’ I want to pass is the value of the input field …
