jquery - How to add additional fields to form before submit? -


is there way use javascript , jquery add additional fields sent http form using post?

i mean:

<form action="somewhere" method="post" id="form">     <input type="submit" name="submit" value="send" /> </form>  <script type="text/javascript">      $("#form").submit( function(eventobj)          {             // want add field "field" value "value" here             // post data              return true;         } </script> 

yes.you can try hidden params.

  $("#form").submit( function(eventobj) {       $('<input />').attr('type', 'hidden')           .attr('name', "something")           .attr('value', "something")           .appendto('#form');       return true;   }); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -