Is there a way to use javascript and JQuery to add some additional fields to be sent from a 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) {
// I want to add a field "field" with value "value" here
// to the POST data
return true;
});
</script>
Try this:
You can add a
hidden
input
with whatever value you need to send:This works:
Yes.You can try with some hidden params.
May be useful for some:
(a function that allow you to add the data to the form using an object, with override for existing inputs, if there is) [pure js]
(form is a dom el, and not a jquery object [jqryobj.get(0) if you need])
Use :
you can use it like that too
you can add # if you like too ("#myformid").