popup on a form submit that passes two variables

Deliguy

New member
Sep 27, 2006
5,162
195
0
Oregon
Hi ALL!

Hopefully one of you javascript pros might be able to help me out with this.

I have a form that passes their name and email address to a script.
When they click the submit button I want a popup in javascript to go to a url and pass the name and email field in the url.

The form is called form1 with the following fields
email_address
first_name

i need it to go to http://www.example.com/something.php?first_name=&email_address=

I'm at a total loss any idears?
 


Code:
<form action="#" onSubmit="window.open('http://example.com/index.php?a=2&b=3', 'newWindow' , 'toolbar=no,scrollbars=yes,width=400,height=300,resizable=yes'); ">
<input type="submit">
</form>
 
sorry i might have worded that confusingly

i meant i want it to getelementbyid to read what they typed in and do the popup. The form needs to go to the action as usual.
 
Code:
<script>
function popIt ( email, name ) {
    var url = "http://example.com/index.php?email=" + email + '&name=' + name;
    window.open(url, 'newWindow' , 'toolbar=no,scrollbars=yes,width=400,height=300,resizable=yes')
}
</script>

<form action="http://actionUrl.com" onSubmit="popIt(document.getElementById('email').value, document.getElementById('name').value);">
<input id="email">
<input id="name">
<input type="submit">
</form>

change accordingly
 
  • Like
Reactions: Deliguy
Code:
<script>
function popIt ( email, name ) {
    var url = "http://example.com/index.php?email=" + email + '&name=' + name;
    window.open(url, 'newWindow' , 'toolbar=no,scrollbars=yes,width=400,height=300,resizable=yes')
}
</script>

<form action="http://actionUrl.com" onSubmit="popIt(document.getElementById('email').value, document.getElementById('name').value);">
<input id="email">
<input id="name">
<input type="submit">
</form>
change accordingly

^this. You could also do it with jquery and a function in the head of your document, but this solution works fine
 
  • Like
Reactions: Deliguy