Onchange="document.forms[0].submit()" - how to CANCEL

Goal: I want to auto-send a form whenever any field changes. The page
will be updated “via Ajax”, so standard submission is cancelled.

Idea: Add onchange=“document.forms[0].submit();” to every field

Problem: Can not cancel form submission. Browser redirects to “results”
page, which is of course JavaScript meant to dynamically update the
page.

RHTML snippet:
<%
remote_form_for :estate, :url => { :action => :evaluate_secondhand_flat
} do |form|
%>
<%=
form.select :province, Constants.provinces_constant, options = {},
:onchange => “javascript: document.forms[0].submit(); /RETURN FALSE
DOES NOT WORK HERE
/”
%>

HTML snippet:

<select id="estate_province" name="estate[province]" 

onchange=“document.forms[0].submit();”>

Please note, that onsubmit already ends with “return false;” but the
cancellation works only with standard submition via submit button.

Thanks in advance!

On 10/28/06, Qertoip [email protected] wrote:

Goal: I want to auto-send a form whenever any field changes. The page
will be updated “via Ajax”, so standard submission is cancelled.

onchange=“this.form.onsubmit;”

Calle D. -*- [email protected]

On 28 October 2006 14:41, Qertoip wrote:

Goal: I want to auto-send a form whenever any field changes. The page
will be updated “via Ajax”, so standard submission is cancelled.

Idea: Add onchange=“document.forms[0].submit();” to every field
I think, the better idea would be to use Rails’ “observe_form” helper
method
which eliminates all the pain of adding onchange handlers to each
control.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs