1

I have on HTML form. I need to convert that form fields into JSON object when I use jQuery "Stringify" it will give name of the object as name and value of the object as value.

function onSubmit( form ){
  var data = JSON.stringify( $(form).serializeArray() );
  alert(data);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<form class="box" onsubmit='return onSubmit(this)'>
  <input type="text" name="tax_val"    class="P_tax_val" size="10" placeholder="Val" value="" required />
 <input type="submit" name="SUBMIT" />
</form>

enter image description here

The above image have name as tax_val and value is 2100 but I need a object as [{"tax_val":"2100"}]

V. Monisha
  • 89
  • 6
  • See [this answer](https://stackoverflow.com/a/31751351/519413) in the duplicate as it handles checkboxes and radios, as well as provides a handy plugin. – Rory McCrossan Jun 20 '19 at 14:43

0 Answers0