# AJAX/RJS Question

**URL:** <https://www.ruby-forum.com/t/ajax-rjs-question/177100>\
**Category:** Deployment\
**Created:** [October 11, 2009, 6:18pm UTC](https://www.ruby-forum.com/t/ajax-rjs-question/177100 "2009-10-11T18:18:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanderkerkoff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7feea3/32.png) [@vanderkerkoff](https://www.ruby-forum.com/u/vanderkerkoff)\
**Post date:** [October 11, 2009, 6:18pm UTC](https://www.ruby-forum.com/t/ajax-rjs-question/177100/1 "2009-10-11T18:18:56Z")

</div>

Hello everyone! How are you doing? I am creating a rails app that  
handles customer records, etc. But, I am having trouble with some  
javascript/ajax stuff.

When creating a customer, the employee will enter in the mailing address  
of the new client. After entering the mailing address it is time to  
enter the billing address. If the billing address is the same, I have  
created a link to simply populate the billing address fields with the  
mailing address fields. This is how I am doing it:

`<%= link_to_remote "Same as mailing.", :url => { :action =>
'set_billing_address' } %>`

Here is my set\_billing\_address.rjs:

* * *

## page[:billing\_address].value = page[:address].value page[:billing\_address2].value = page[:address2].value … and so on

Well, the billing\_address fields are not being populated. I do have all  
the id’s set etc. Just to make sure, I did a:

* * *

## page[:billing\_address].value = ‘test’ page[:billing\_address2].value = ‘test’ … and so on

That works just fine.

So, I figured out that I have to pass the values along when I call  
link\_to\_remote. That works perfect. But my question is, how do I get the  
value for the text fields so I can do something like:

* * *

## link\_to\_remote “Same as above”, :url =\> { :action =\> ‘set\_billing\_address’, :address =\> ‘somehow get the text field value for address’, :city =\> ‘somehow get the city from text field’) … and so on

I have been searching Google and Rails documentation, but no luck. I  
would appreciate any help!

Thanks,

matt

---

<div class="post-metadata">

**Author:** ![vanderkerkoff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7feea3/32.png) [@vanderkerkoff](https://www.ruby-forum.com/u/vanderkerkoff)\
**Post date:** [October 11, 2009, 6:56pm UTC](https://www.ruby-forum.com/t/ajax-rjs-question/177100/2 "2009-10-11T18:56:36Z")

</div>

Matt Do wrote:

> Hello everyone! How are you doing? I am creating a rails app that  
> handles customer records, etc. But, I am having trouble with some  
> javascript/ajax stuff.
> 
> When creating a customer, the employee will enter in the mailing address  
> …

Okay, I figured it out. I have to pass link\_to\_remote with ‘with.’ I  
found the solution here (if anyone is also looking for it):

[http://www.ruby-forum.com/topic/180603](http://www.ruby-forum.com/topic/180603)
