I have this form below when i submit it i want it to append a value to the 6 urls generated from a php query.
<form id="emailform" action="" method="post">
<input type="text" value="" size="30" name="email" id="email">
<input type="submit" name="submit" value="Submit" class="continue-button">
</form>
This is an example of my link, sitename/demo.php?1=demo&2=haha
How can i use the form and jquery to append &email=formvalue
to the url so sitename/demo.php?1=demo&2=haha
= sitename/demo.php?1=demo&2=haha&email=formvalue
?
Please keep in mind that these urls are generated dynamically with a query.
I tried using attr on a but it doesnt work. I know you have to check for the submit then use attr.
$('#emailForm').submit(function(){ //listen for submit event
}
I have this form below when i submit it i want it to append a value to the 6 urls generated from a php query.
<form id="emailform" action="" method="post">
<input type="text" value="" size="30" name="email" id="email">
<input type="submit" name="submit" value="Submit" class="continue-button">
</form>
This is an example of my link, sitename./demo.php?1=demo&2=haha
How can i use the form and jquery to append &email=formvalue
to the url so sitename./demo.php?1=demo&2=haha
= sitename./demo.php?1=demo&2=haha&email=formvalue
?
Please keep in mind that these urls are generated dynamically with a query.
I tried using attr on a but it doesnt work. I know you have to check for the submit then use attr.
$('#emailForm').submit(function(){ //listen for submit event
}
Share
Improve this question
edited Feb 26, 2014 at 4:21
Mr Johnson
asked Feb 24, 2014 at 6:58
Mr JohnsonMr Johnson
651 silver badge7 bronze badges
3
- use $(form).serialize(); to pass through ajax – kamesh Commented Feb 24, 2014 at 7:01
- it should happen automatically.. did you try pressing submit button? – Mr_Green Commented Feb 24, 2014 at 7:01
- I rewrote the question more clearly – Mr Johnson Commented Feb 26, 2014 at 4:21
3 Answers
Reset to default 4You can use hidden field like this
<form action="" method="post">
<input type="hidden" name="new_value" value="value"/>
<input type="text" value="" size="30" name="email" id="email">
<input type="submit" name="submit" value="Submit" class="continue-button">
</form>
or you can add to action of form like this
<form action="http://action_url?new_value=value" method="post">
<input type="text" value="" size="30" name="email" id="email">
<input type="submit" name="submit" value="Submit" class="continue-button">
</form>
You'd better to use markup input type="hidden" to submit the value Your Form :
<form action = "sitename./demo.php" method="post" >
<input type="hidden" name="1" value="demo" />
<input type="hidden" name="2" value="haha" />
<input type="text" value="" size="30" name="email" />
<input type="submit" name="submit" value="Submit" class="containue-button" />
</form>
Then you just need to submit this form in javascript or jquery. : )
use serilaize method
$('#emailForm').submit(function(){
//listen for submit event
var all_submit_data = $( '#emailForm' ).serialize() ;
//this will have all input fields values in serilized
}
ref : https://api.jquery./serialize/