Re: can't reset a hidden field in form




Evertjan. wrote:
RobG wrote on 13 aug 2007 in comp.lang.javascript:

I think IE7 and Safari3.0 are in error, logically speaking.
Technically it is a question of specification.

Personally, I think IE7 and Safari are right. The user tells the browser
"Reset this form" and that is what the browser does. FF and Opera don't
do what the user asked it to do.

I think you're right.

Resetting the form should set all values back to their initial value
which is set by the value attribute in the HTML. The initial value is
stored in the DOM defaultValue property, resetting the form should set
all controls back to the defaultValue.

Resetting a form should set all controls back to their defaultValue.
I don't see anywhere that programmatically changing the value
attribute should change the defaultValue property for hidden controls
only:

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

Specification is not neccessarily logical and
why would you call a hidden field a "control"?''

Because that is what it is:

<URL: http://www.w3.org/TR/html4/interact/forms.html#hidden-control >


I think that if the clientside js altered a hidden field,
it is the responsability of that js [programmer] to reset it or not
after detecting the user's actions:

That is purely your opinion and seems at odds with the specification:

"Each control has both an initial value and a current value, both of
which are character strings... ... a control's "initial value" may be
specified with the control element's value attribute...

"The control's "current value" is first set to the initial value.
Thereafter, the control's current value may be modified through user
interaction and scripts.

"A control's initial value does not change. Thus, when a form is
reset, each control's current value is reset to its initial value. If
a control does not have an initial value, the effect of a form reset
on that control is undefined."

<URL: http://www.w3.org/TR/html4/interact/forms.html#h-17.2 >

I can't see how anyone can interpret that as requiring hidden controls
that have been modified by script to also be reset by script.

<input type='reset'
onclick='return manipulateHiddenFieldsAsRequired(this);'>

btw, the whole idea of using the html reset button function in a js
governed form is often not the most versatile solution,
especially in a cross browser environment.

Perhaps, depending on the situation. But that is not the issue here,
it is that some browsers do not reset controls to their initial value
when the W3C specification states that they should.


--
Rob

.



Relevant Pages

  • Re: cant reset a hidden field in form
    ... "Reset this form" and that is what the browser does. ... Resetting the form should set all values back to their initial value ... stored in the DOM defaultValue property, ... Resetting a form should set all controls back to their defaultValue. ...
    (comp.lang.javascript)
  • Re: cant reset a hidden field in form
    ... "Reset this form" and that is what the browser does. ... Resetting the form should set all values back to their initial value ... stored in the DOM defaultValue property, ... Resetting a form should set all controls back to their defaultValue. ...
    (comp.lang.javascript)
  • Re: Checking if form values have changed between postbacks
    ... Yeh I should have been clearer, its not a reset button but a link to return ... "Hermit Dave" wrote: ... > viewstate or session object or even a cache object ... The controls would reflect the state ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: cant reset a hidden field in form
    ... "Reset this form" and that is what the browser does. ... stored in the DOM defaultValue property, ... Resetting a form should set all controls back to their defaultValue. ... It is a bug. ...
    (comp.lang.javascript)
  • Re: Too Many Fields Defined?????
    ... as adding and deleting especially using old flat files with way to many ... field in a table does *not* increment the field counter. ... the 700-odd limit on controls. ... Compacting does *not* reset the ...
    (microsoft.public.access.forms)