# How to get the value?

**URL:** <https://www.ruby-forum.com/t/how-to-get-the-value/182253>\
**Category:** Rails\
**Created:** [January 25, 2010, 5:55pm UTC](https://www.ruby-forum.com/t/how-to-get-the-value/182253 "2010-01-25T17:55:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcieong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@mcieong](https://www.ruby-forum.com/u/mcieong)\
**Post date:** [January 25, 2010, 5:55pm UTC](https://www.ruby-forum.com/t/how-to-get-the-value/182253/1 "2010-01-25T17:55:46Z")

</div>

I wrote a small helper which receive a parameter “f”, as following:

def cno\_helper(f)  
concat “”  
concat “\<div class=‘auto\_complete’ id=’” + f + “\_auto\_complete’”  
concat  
“style=‘display:none;border:none;background-color:white;height:150px;overflow:none;cellpadding:0;cellspacing:0’\>”  
concat “”

```
concat auto_complete_field( f,
      :frequency => 0.4,
      :min_chars => 2,
      :method => 'GET',
      :url=>{:action=>'autocomplete_vc_cno'},
      :tokens => ',')

```

end

It generate the code I want, and the auto\_complete\_field is working.  
The program is I don’t know how to pass the current value of the input  
field to the :action ‘autocomplete\_vc\_cno’.

Any idea? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mcieong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@mcieong](https://www.ruby-forum.com/u/mcieong)\
**Post date:** [January 25, 2010, 6:09pm UTC](https://www.ruby-forum.com/t/how-to-get-the-value/182253/2 "2010-01-25T18:09:56Z")

</div>

You can send it as a :with param.

concat auto\_complete\_field( f,

> ```
> :frequency => 0.4,
> :min_chars => 2,
> :method => 'GET',
> :url=>{:action=>'autocomplete_vc_cno'}, :with => " 'val=' + this.value ",
> :tokens => ',')
> 
> ```
> 
> end

---

<div class="post-metadata">

**Author:** ![mcieong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@mcieong](https://www.ruby-forum.com/u/mcieong)\
**Post date:** [January 26, 2010, 1:32am UTC](https://www.ruby-forum.com/t/how-to-get-the-value/182253/3 "2010-01-26T01:32:18Z")

</div>

Chris H. wrote:

> You can send it as a :with param.
> 
> concat auto\_complete\_field( f,
> 
> > ```
> > :frequency => 0.4,
> > :min_chars => 2,
> > :method => 'GET',
> > :url=>{:action=>'autocomplete_vc_cno'}, :with => " 'val=' + this.value ",
> > :tokens => ',')
> > 
> > ```
> > 
> > end

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![mcieong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@mcieong](https://www.ruby-forum.com/u/mcieong)\
**Post date:** [January 26, 2010, 5:10pm UTC](https://www.ruby-forum.com/t/how-to-get-the-value/182253/4 "2010-01-26T17:10:37Z")

</div>

Mc Ieong wrote:

> Chris H. wrote:
> 
> > You can send it as a :with param.
> > 
> > concat auto\_complete\_field( f,
> > 
> > > ```
> > > :frequency => 0.4,
> > > :min_chars => 2,
> > > :method => 'GET',
> > > :url=>{:action=>'autocomplete_vc_cno'}, :with => " 'val=' + this.value ",
> > > :tokens => ',')
> > > 
> > > ```
> > > 
> > > end
> 
> Thanks a lot!

It should be:

concat auto\_complete\_field( f,  
:frequency =\> 0.4,  
:min\_chars =\> 2,  
:method =\> ‘GET’,  
:url=\>{:action=\>‘autocomplete\_vc\_cno’}, :with =\> " ‘val=’ +  
document.getElementById(’" + f + "’).value ",  
:tokens =\> ‘,’)

Thanks!
