Topic: passing a querystring param in link_to_function

my rhtml has the script mentioned below, however, I dont have a form tag.
model_attribute mentioned in the script is a text field name in the same html.

<%= link_to_function 'showDesc', 'document.location.href="/adf_sku_group/showDesc?descr="+$("model_attribute") ' %>

it appears to me that there is something missing, I am unable to retrieve the value of the querystring parameter when I click on the link.

any help is appreciated

Thanks

Re: passing a querystring param in link_to_function

'document.location.href="/adf_sku_group/showDesc?descr="+$("model_attribute")'

$("model_attribute") gets the DOM element with id "model_attribute" -- where value is a property of that element.

Try this instead:

'document.location.href="/adf_sku_group/showDesc?descr="+$F("model_attribute")'

Prototype's $F() function returns the value of a form input control. See here for more details:

http://prototypejs.org/api/utility#method-$f

Re: passing a querystring param in link_to_function

CAN you suggest a tutorial that has these hidden tricks?

Re: passing a querystring param in link_to_function

Functions such as $F() aren't "hidden": Rails uses the Prototype.js library extensively. You can find the official Prototype docs here:

http://prototypejs.org/

They have a tips and tutorials section as well:

http://prototypejs.org/learn

This is also a good resource (it was the "go-to" place for info before the API was developed):

http://www.sergiopereira.com/articles/prototype.js.html

Hope that helps!