Forum: Ruby on Rails onchange inside form_remote_tag

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
adam (Guest)
on 2005-11-12 12:49
(Received via mailing list)
What is the correct way to use an onchange inside a <select> of  a <%=
form_remote_tag %> block ?

When i do  <select name=field onchange="this.form.submit()"> it does not
update the DOM element, but posts to a new page.  A normal submit button
however works.  Is there a proper way to have this form_remote submit
with an onchange ?

thanks
adam
pmr16366 (Guest)
on 2005-11-12 12:49
(Received via mailing list)
I had the same problem. My rather ugly workaround was to put the form
submit
button inside a hidden div and have the onchange click the button.
 I remember reading another way of doing it too, but cant remember what.
 Paul
bruno.celeste (Guest)
on 2005-11-12 12:49
(Received via mailing list)
I resolved this problem in a rails app, it's not pretty but I didn't
find a better solution ;)

<select name="actions"
onchange="document.getElementById('submitchangeitem').click();">
<option value="1">1</option>
</select>
<input type="submit" id="submitchangeitem" value="Change!" />

Hope it helps!

2005/11/8, Paul Rogers <pmr16366@gmail.com>:
adam (Guest)
on 2005-11-12 12:49
(Received via mailing list)
that worked thanks.

i did it like this

  <select onchange="document.getElementById
('submit_location_id').click();" id=location_id name=location_id>
.
.
.
   <span style="display:none;"><input type=submit
id='submit_location_id'></span>
This topic is locked and can not be replied to.