# Need help with remote\_form\_for using onSelect instead of onSubmit

**URL:** <https://www.ruby-forum.com/t/need-help-with-remote-form-for-using-onselect-instead-of-onsubmit/138223>\
**Category:** Rails\
**Created:** [May 21, 2008, 6:15am UTC](https://www.ruby-forum.com/t/need-help-with-remote-form-for-using-onselect-instead-of-onsubmit/138223 "2008-05-21T06:15:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ncancelliere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@ncancelliere](https://www.ruby-forum.com/u/ncancelliere)\
**Post date:** [May 21, 2008, 6:15am UTC](https://www.ruby-forum.com/t/need-help-with-remote-form-for-using-onselect-instead-of-onsubmit/138223/1 "2008-05-21T06:15:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ncancelliere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@ncancelliere](https://www.ruby-forum.com/u/ncancelliere)\
**Post date:** [May 21, 2008, 8:34am UTC](https://www.ruby-forum.com/t/need-help-with-remote-form-for-using-onselect-instead-of-onsubmit/138223/2 "2008-05-21T08:34:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ncancelliere](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9f8e36/32.png) [@ncancelliere](https://www.ruby-forum.com/u/ncancelliere)\
**Post date:** [May 28, 2008, 12:03am UTC](https://www.ruby-forum.com/t/need-help-with-remote-form-for-using-onselect-instead-of-onsubmit/138223/3 "2008-05-28T00:03:43Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
