How to set onclick function for select_tag?

I want to use select_tag helper but how to set a onclick function? where
should I define this function?

thanks.

I don’t think IE supports onlick on the select tag. You may want to
look at setting the onclick for the options tags inside the select.

Ryan wrote:

I don’t think IE supports onlick on the select tag. You may want to
look at setting the onclick for the options tags inside the select.

Hi Ryan,

Can I let onclick refer to a function defined in the controller?

Zhao Yi wrote:

Can I let onclick refer to a function defined in the controller?

In HTML it’s:

onclick=‘Ajax.Request(…)’

In Ruby that’s :onclick => ‘Ajax.Request(…)’, natch.

To get the … part, write remote_function or link_to_remote into a web
page and
view its source. That will show you how to pack the Request arguments.


Phlip

Phlip wrote:

In HTML it’s:

onclick=‘Ajax.Request(…)’

In Ruby that’s :onclick => ‘Ajax.Request(…)’, natch.

To get the … part, write remote_function or link_to_remote into a web
page and
view its source. That will show you how to pack the Request arguments.


Phlip

Sorry I am new to rails and don’t understand your comments.
I have a select box and I want whenever its value changed, other text
field value will change accordingly. Could you please give me an example
for this?

thanks.

Zhao,

Take a look at the excelent screencasts by Ryan B. (specially
episode #88 and others on AJAX, RJS and JQuery) at:

Cheers, Sazima