# AJAX/RJS Same as mailing address type function

**URL:** <https://www.ruby-forum.com/t/ajax-rjs-same-as-mailing-address-type-function/177070>\
**Category:** Rails\
**Created:** [October 10, 2009, 11:23pm UTC](https://www.ruby-forum.com/t/ajax-rjs-same-as-mailing-address-type-function/177070 "2009-10-10T23:23:59Z")\
**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 10, 2009, 11:23pm UTC](https://www.ruby-forum.com/t/ajax-rjs-same-as-mailing-address-type-function/177070/1 "2009-10-10T23:23:59Z")

</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:

```auto
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:

```auto
page[:billing_address].value = 'test'
page[:billing_address2].value = 'test'
... and so on
```

That works just fine.

Are the values of the fields not passed into the javascript when doing a  
link\_to\_remote, is that why it is not working?

I have been searching Google, 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:57pm UTC](https://www.ruby-forum.com/t/ajax-rjs-same-as-mailing-address-type-function/177070/2 "2009-10-11T18:57:11Z")

</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)
