Submit AJAX form with select onchange

Hey all,

I’m trying to submit the following ajax form using the onchange on a
rails select.

<% form_remote_tag(:url => { :action => :add_facilitator }, :html =>
{:id => ‘add_facilitator’}) do %>
<%= select :facilitator, :id, @facilitators.map{|u|
[u.surname,u.id]}, {:include_blank => ‘’, :onchange =>
“‘add_facilitator’.onsubmit()”}%>
<% end %>

If I add a submit tag it works perfectly but i’d rather use onchange
instead.

any help is greatly appreciated.

j

On 14 Aug 2008, at 13:06, [email protected] wrote:

“‘add_facilitator’.onsubmit()”}%>
<% end %>

$(‘add_facilitator’).submit()

Fred

HI Fred,

Thanks for the reply.

jj

On Aug 14, 1:06 pm, “[email protected][email protected]

Hi Fred,

Thanks for the reply, however, even with your code, the following is
the html produced by the helper. There is no onchange in the select
definition.

jj

Any ideas?

j

On Aug 14, 1:11 pm, Frederick C. [email protected]
wrote:

{:id => ‘add_facilitator’}) do %>

If I add a submit tag it works perfectly but i’d rather use onchange
instead.

any help is greatly appreciated.

j

On 14 Aug 2008, at 13:11, Frederick C. wrote:

{:id => ‘add_facilitator’}) do %>
<%= select :facilitator, :id, @facilitators.map{|u|
[u.surname,u.id]}, {:include_blank => ‘’, :onchange =>
“‘add_facilitator’.onsubmit()”}%>
<% end %>

$(‘add_facilitator’).submit()

oh and you need to make the onchange be in the second options hash, ie
{:include_blank => true}, {:onchange => …}}

Fred

Did that Fred and it worked.

Thanks for your help.

On Aug 14, 1:28 pm, Frederick C. [email protected]

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