need help with remote_form_for using onSelect instead of onSubmit

I'm building a calendar/scheduling application that has a bunch of little pulldowns to let doctors note appointment status for a given timeslot. I got the ajax call working with a submitbutton - but I really want it to update the database as soon as a doctor selects a new value for the appointment status.

<% remote_form_for(slot.get_todays_appointment do |f| %>   <%=h slot.get_todays_appointment.patient.first_last_name %>    <%= f.select :status, Appointment::STATUS_TYPES, :prompt => false %>   <%= submit_tag "Update" %> <% end %>

I've tried to use an observer tied to the drop-down but that keeps returning 'null value' and I've tried to use everything I can think of for the identifier 'appointment_status' and 'appointment[status]'. Here's the HTML that the above ruby code generates:

<form action="/appointments/813" class="edit_appointment" id="edit_appointment_813" method="post" onsubmit="new Ajax.Request('/ appointments/813', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this) + '&amp;authenticity_token=' + encodeURIComponent('3fd6efde2ce33fadfa8a695b23f6be6b67c111df')}); return false;"> <div style="margin:0;padding:0">     <input name="_method" type="hidden" value="put" />     <input name="authenticity_token" type="hidden" value="3fd6efde2ce33fadfa8a695b23f6be6b67c111df" /> </div> David Atkinson <select id="appointment_status" name="appointment[status]">     <option value="">---</option>     <option value="211" selected="selected">211</option>     <option value="213">213</option>     <option value="214">214</option>     <option value="215">215</option>     <option value="PM">PaceMkr</option>     <option value="HS">Hospital</option>     <option value="NS">No Show</option>     <option value="CX">Complic</option>     <option value="SA">Schdl Abs</option> </select> <input name="commit" type="submit" value="Update" /> </form>

So what am I doing wrong? I just want to be able to have the form submit onChange rather than having someone have to click a button.

So they key bit here is the observer, but that's the bit you haven't shown :-). Alternatively stick an onChange on your select

Fred

I figured it out -- you simply attach the observer ... I was making it more complicated than it was. Makes me love Rails all the more -- so simple!

Nicholas