I try to set some hidden form field values with an onclick event. Ok, after I did something like this:
document.getElementById('hidden_field').value = 123;
I can output the value with the firebug console by entering this:
alert(document.getElementById('hidden_field').value);
So the values are definitely set. But now when I submit the form, the hidden field values are still empty.
Do you have any idea whats going wrong?
I try to set some hidden form field values with an onclick event. Ok, after I did something like this:
document.getElementById('hidden_field').value = 123;
I can output the value with the firebug console by entering this:
alert(document.getElementById('hidden_field').value);
So the values are definitely set. But now when I submit the form, the hidden field values are still empty.
Do you have any idea whats going wrong?
Share Improve this question edited Apr 19, 2014 at 7:48 tshepang 12.5k25 gold badges97 silver badges139 bronze badges asked Jun 3, 2010 at 12:32 ownkingownking 2,0061 gold badge26 silver badges34 bronze badges 3- 2 You will need to post your HTML – Keith Rousseau Commented Jun 3, 2010 at 12:36
- Check if your 'hidden_field' is inside the form element, it contains name and id attributes and form is posted correctly. – Nilambari Commented Jun 3, 2010 at 12:37
- 1 You can install something like TamperData to see what's in the actual HTTP request/response blocks. – Pointy Commented Jun 3, 2010 at 12:37
1 Answer
Reset to default 12Make sure your hidden field has the name
attribute:
<input id="hidden_field" name="hidden_field" type="hidden" value="123" />
Inputs without a name
attribute aren't sent with the request.