1

I'm trying update some values for some hidden input boxes, but I'm not very successful. I have no problem doing this to visible input[type=text].

Here is a small example: http://jsfiddle.net/saHCU/

Use Firebug to see the hidden fields.

You can see the value added to the text box for item_id3. But when you look at the source, none of the text boxes has an updated value.

Why is this not updated?

kapa
  • 77,694
  • 21
  • 158
  • 175
Steven
  • 19,224
  • 47
  • 152
  • 257

1 Answers1

4

Because it does not change the attribute, but the underlying property.

The HTML value attribute can be considered more like a "starting point", what really matters is the property itself (element.value = 1 in Javascript). If you try to submit your form, or query the value with Javascript, you will see that is has actually changed, so your code is working fine.

Also, as far as my knowledge goes, there is not input type="textbox", only input type="text".

Community
  • 1
  • 1
kapa
  • 77,694
  • 21
  • 158
  • 175
  • So it doesn't matter if the input is hidden? `textbox` was just a typo, of course it is `text`. And is it a Firebug bug that the values are not shown in source? Thanks for your answer. – Steven Jul 17 '12 at 21:01
  • @Steven It does not matter at all. And again, it is not a bug. Firebug shows attributes, not properties. If you try to query the property from the console, you will see that it is actually set. – kapa Jul 17 '12 at 21:14