Set hidden form field values with JavaScript but request still empty
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 enteri开发者_运维技巧ng 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?
Make 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.
精彩评论