ncancelliere
2008-May-21 04:14 UTC
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) + ''&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. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-21 06:33 UTC
Re: need help with remote_form_for using onSelect instead of onSubmit
On 21 May 2008, at 05:14, ncancelliere wrote:> > 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: >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 --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ncancelliere
2008-May-27 22:01 UTC
Re: need help with remote_form_for using onSelect instead of onSubmit
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 Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 21 May 2008, at 05:14, ncancelliere wrote: > > > > > > > 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: > > 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--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---