How to make a drop-down automatically submit an AJAX form

Hi,
I know that to make a dropdown box automatically submit when you change
the value, you do this:
<select … onchange=“this.form.submit();”>
BUT i’ve got an ajax form, and if i do the above trick, it simply
reloads the ajax partial into the whole screen, rather than into the div
where it is meant to go.
I’ve already got it all working so that if you click on the submit
button, all is fine, but i’d like to know how to make it automatic.

My RHTML code looks a bit like this:


<%= form_remote_tag :update => “div_id_dataentry_bottom_ajax”, :url => {
:action => “dataentry_bottom_edit” } %>


<%= options_from_collection_for_select @departments, “id”,
“department_name” %>

<%= submit_tag “Open for Data Entry” %>

<%= end_form_tag %>

--

Cheers, thanks all

Anyone?

Use onchange=“this.form.onsubmit();” rather than submit straight.

Raghuraman Suraj wrote:

Use onchange=“this.form.onsubmit();” rather than submit straight.

Brilliant!

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