The form reset() function does not always work as expected. The following simple code illustrates this. <form> <input type="hidden" name="name" value="bamm"> <input type="submit"> </form> <script> var q = document.forms; document.write(q.name.value + '<br>'); q.name.value = 'bamm2'; document.write(q.name.value + '<br>'); q.reset(); document.write(q.name.value + '<br>'); </script> The output of this code in Mozilla and Firefox is as follows: bamm bamm2 bamm2 The output of the same code in Konqueror is bamm bamm2 bamm The output of the same code in Internet Explorer is bamm bamm2 bamm I haven't checked it in Safari, but I would expect it to be the same as in Konqueror. Since Konq, Internet Explorer and Safari are default browsers in their respective platforms, most webmasters probably code according to expected results in these browsers, which is different from Mozilla. I also believe the results in Konq and IE are correct because the reset() function should restore all values to whatever they were when the page was first loaded.
Not a JS engine issue. I believe changing "value" before the user has changed it will also change the defaultValue in Mozilla, for compat with IE... There are bugs with lengthy discussions of the bizarre relationship between .value and the value attribute in IE, which I recommend reading.
Boris, please show me where I can read about this? Is there a standard for this? Is Konqueror and IE wrong? If Moz's action is standard then the standard just doesn't make sense to me.
This seems like a valid bug to me. We shouldn't be doing any stupid things with value changing the "value" attribute and thus the defaultValue DOM attribute.
input type=hidden is in the 'default' state, and the spec states: | The value IDL attribute allows scripts to manipulate the value | of an input element. The attribute is in one of the following | modes, which define its behavior: | ... | default | On getting, if the element has a value attribute, it must | return that attribute's value; otherwise, it must return | the empty string. On setting, it must set the element's | value attribute to the new value. <http://www.whatwg.org/html/#dom-input-value>.
Ah, yeah, my bad.
(Though looking at the dates, I guess it's likely the spec changed in the meantime!)