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:

David Atkinson --- 211 213 214 215 PaceMkr Hospital No Show Complic Schdl Abs

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.

On 21 May 2008, at 05:14, ncancelliere wrote:

<%= 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:

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

On May 21, 1:33 am, Frederick C. [email protected]