Reputation:
I want to read a value in the hidden field in javascript/Jquery.How can i acheive this ??
Upvotes: 0
Views: 461
Reputation: 8071
This an example to read and write value just with pure javascript.
<input type="hidden" id="field-id" />
<script type="text/javascript">
document.getElementById('field-id').value = "your value which you want to insert";
alert(document.getElementById('field-id').value);
</script>
Upvotes: 0
Reputation: 4892
<input type="hidden" value="12345" id="ixd" name='ixd' />
var val = document.getElementById("ixd").value;
Upvotes: 0
Reputation: 6532
Use the field name or id, e.g.
var fVal = $('[name="name"]').val();
var fVal = $('#id').val();
Upvotes: 0
Reputation: 26753
It's the same as for a regular field:
document.forms[xxx].elements[yyyy].value
xxx is the name of the form, or its number. yyyy is the name of the element (or its number).
You can also use document.getElementById()
to get either the form or the field.
Upvotes: 0
Reputation: 9289
try this
var value=$('#HidennfieldID').val()
value will hold the value of hidden field
Upvotes: 4