Random_Display_Name Random_Display_Name - 1 year ago 109
Javascript Question

Form submit with hidden fields

I've got a form with 2 Hidden Fields and i want , when i hit the submit button to fill the fields with my script before sending it . My form looks like this :

<form method = "post" action = "Submit.php">
<input type="text" value="" >
<input type"hidden" value="" >
<input type"hidden" value="" >

<input type="submit" value="Sendme">

<script > //do something before send form </script>

The problem is that ive got a field at the end of my form and i need the value of it to fill the hidden fields with some calculation based on his value before the form is submitted.

Answer Source

As per your question, I assumed that you want to set the values for hidden fields based on the calculation done on the entered value for a first text-box.

You can use the change method of the text-box to set the values of hidden fields, once you submit that will give you values of all the fields.

<input type="text" value="" id="inputBox">

<input type="hidden" value="" id="hidden1">
<input type="hidden" value="" id="hidden2">

   var value = $(this).val() + 10;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download