Set hidden field value in JS

September 7, 2020

How to set the hidden field value with Javascript code before you submit the form

Define your hidden field as below

<input type="hidden" id="h-field" value="1" />

Now we will see how you can change the hidden field value before you submit the form