Reputation: 1
i have stored email_id from first form using jQuery.But how can i use it second form's action:mailto:
?
<form id="sForm" action="mailto:[email protected]" method="post" enctype="text/plain">
<label for="name">Name *</label>
<input type="text" name="name" style="width: 100%;"><br>
<label for="email">Email Address *</label>
<input type="text" name="email" id="email" style="width: 100%;"><br>
<input type="submit" value="Send" >
<input type="reset" value="Reset">
</form>
<script>
$(document).ready(function(e){
$('#sForm').on('submit',function(){
var email_var = document.getElementById('email').value;
});
});
</script>
<form id="pForm" action="mailto:???" method="post" enctype="text/plain">
....
</form>
Upvotes: 0
Views: 319
Reputation: 162
Also you can use some function in the "action" of the second form. example;
<script>
var email = 'mailto:';
$(document).ready(function(e){
$('#sForm').on('submit',function(){
email += document.getElementById('email').value;
});
});
function getMail(){
return email;
}
</script>
<form id="pForm" action="javascript:getMail()" method="post" enctype="text/plain">
Upvotes: 0
Reputation: 15711
$(document).ready(function(e){
$('#sForm').on('submit',function(){
document.getElementById('pForm').action = 'mailto:'+document.getElementById('email').value;
});
});
Instead of storing the email in an unused variable, change the action of the form to the right mailto:
Upvotes: 1