On May 1, 1:49 am, russellneufeld <russellneuf...@gmail.com> wrote:
> Hi all,
>
>   I've got a set of forms which all act the same way - the form submit
> is handled by the jQuery form plugin which redirects the output to a
> div on the page.  That means that when the user hits submit, the page
> in the browser doesn't change.  The success or failure of the form
> submit is displayed on the existing page.
>
>   The pages all have a "submit" and a "reset" button.  The issue is
> that the reset button holds the state of the form when the page was
> originally sent to the browser.

Only if you do that yourself, normally the reset button effectively
does nothing more than call the reset method of the form.

> That means that after someone changes
> the form and submits it successfully, the reset button returns the
> form to the previous state when the page was originally sent to the
> browser.  But that state doesn't really reflect the current state of
> the form variables (as held on the server) since an update has been
> made.

Form controls have either a defaultValue, defaultChecked or
defaultSelected property, depending on the type of element, that holds
the default value of the control.  When the form is reset, the
control's value is reset to the relevant default.


>   My question is this - is there a way to update the reset button so
> that it resets the form to a new state, one that might have changed
> since the browser originally rendered the page?

Change the default[Value|Checked|Selected] property to whatever you
want, then the reset button will reset to that value.

<URL: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26091157 >
<URL: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-37770574 >


--
Rob

Reply via email to