AJAX/RJS Question

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs