change a value inside button_to_function with js


I've been toying with something similar which might help you. In
remote_function method, I wanted to insert some javascript to
dynamically calculate the URL but the remote_function method wanted to
use a string for URL. So I kludged my way through it with the

remote_function(:url => "'+this.form.action+'", :update => "'
+'_update", ...[other params]...)

Can you see what I'm doing? It's hard to read - note that everything
between the double quotes is all javascript. It's easier to read once
you know that. Basically, I'm writing javascript that closes the
string quote that remote_function opens for :url, and then I insert
some javascript code (and reopen the string and add text in the case
of the "update" param). This results in Javascript that looks like:

new Ajax.Updater('''_update', ''+this.form.action+'')

I think it's a pretty clean way of generating dynamic JS code in Rails
js helper functions. It's a little fugly but not too bad..