Steven
Steven

Reputation: 19425

Not able to change value of hidden input textbox using jQuery

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?

Upvotes: 1

Views: 1556

Answers (1)

kapa
kapa

Reputation: 78671

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".

Upvotes: 4

Related Questions