Ruby on Rails Sunday, October 3, 2010

On 3 October 2010 02:09, zalek <zalekbloom@hotmail.com> wrote:
> I want to add a Javascript function with "onclick"
> function. How can I do it?
>
>        <%= f.select :backgroud_picture, my_pictures %>

You probably don't want onClick; onChange is more likely to be more
usable with a select box, but either way, just add it to the f.select
(here's an example I've used with a select_tag, but the principle's
the same) :

<%= select_tag("note[notes]", options_for_select([["quick note",
""], ["no answer", "Called, no answer"], ["no show", "Appointment no
show"]]), :onchange => "if(this.value != '' && confirm('Create quick
note?')){this.form.submit()}") %>

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment