Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6052331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:55:01+00:00 2026-05-23T07:55:01+00:00

I discovered something surprising: <html> <head> <script type=text/javascript> function f() { document.getElementById(h).value++; document.getElementById(x).value++; }

  • 0

I discovered something surprising:

<html>
<head>
<script type="text/javascript">
function f()
{
document.getElementById("h").value++;
document.getElementById("x").value++;
}
</script>
</head>
<body>

<form>
<input type="hidden" name="hidden" id="h" value="5"/>
<input type="text" id="x" value="5"/>
<input name='clear' type='reset' id='clear' value='Clear'>
</form>

<button type="button" onclick="f()">Increment</button>
<button type="button" onclick="alert(document.getElementById('h').value)">Show hidden</button>

</body>
</html> 

Trying this in Firefox 4.0.1, clicking clear always resets the text input to 5, but never resets the hidden field.

I (and others) did not expect this behavior at all: we expected the hidden value to get reset too!

Can anyone point to either documentation or specs that explain why the hidden input is treated differently by the reset button?

Explanations as to why such behavior is desirable are also welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:55:01+00:00Added an answer on May 23, 2026 at 7:55 am

    FWIW, I think I can put together the full story from the answers and comments.

    Usage rationale: The clear button is intended for clearing user input, and since hidden inputs are not directly accessible by the user, it doesn’t make sense to allow the user to reset the hidden input’s value.

    Documentation and behavior:
    The bug report that AR pointed out is explicit about what is happening: The hidden field’s value‘s mode is default, as is intended in the specs.
    Particularly, this means that changing the value (as in the sample code in the question) changes the default value, and the reset button resets input fields to the default value, hence there is no change.
    The behavior for the text input is different (even though its value is also changed programmatically) because its value‘s mode is not default but value, which means that there is a distinction between the default value of the input and the current value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today I discovered something that makes me sad: objects of type System.Generic.Collections.List don't have
I was debugging something and discovered some strangeness in JavaScript: alert(1=='') ==> false alert(0=='')
I'm currently doing some last-measure optimizations, mostly for fun and learning, and discovered something
I just discovered a bug where the code looked something like this: char *foo
I've discovered this idiom recently, and I am wondering if there is something I
I discovered something odd that I can't explain. If someone here can see what
I've discovered something pretty amazing that works recently. I am wanting to know if
So we went to implement something today, and discovered that there already is several
I've just discovered the email-address-saving form on my website does not work on Opera
Something I discovered I like about C# are properties & String.Format. Does something like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.