tags:

views:

1282

answers:

4

Hey guys im pretty new to codeing and am looking for a little help.

I have a submit form and want it to open a new window when users submits the form so i can track it on analytics.

here is the code i'm using.

<form action="http://URL at mailchimp subscriber URL.com" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank"
onclick=window.open(google.html,'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');
>
<label for="name">Your Name</label><input type="text" value="" name="FNAME" class="required" id="mce-FNAME">
<br/>
<br/>
<label for="email">Your Email </label><input type="text" value="" name="EMAIL" class="required email" id="mce-EMAIL">

<br/>
<br/>
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="submit">
</form></div>

Thanks in advance

A: 
<form target=_blank action="http://URL at mailchimp subscriber URL.com" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank"
onclick=window.open(google.html,'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');
>

you have to add a target=_blank attribute in your form tag.

Konstantinos
if you add the target=_blank, you don'y need the onClick event.
Hugo
This is still wrong, for multiple reasons. Most of the quoting's missing, and it will fire anytime the form is clicked for any reason, not only at submit.
Matthew Flaschen
A: 

window.open doesn't work across all browsers, Google it and you will find a way of detecting the correct dialog type.

Also, move the onlick call to the input button for it to only fire when the user submits.

ck
onclick on the input button is wrong. Then, if the user clicks it, but moves away before releasing, it will still fire.
Matthew Flaschen
+1  A: 

The code you have given, needs to be corrected. In form tag you have to enclosed the onClick attribute value in double quote:

"window.open('google.htm','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');"

You also need to take care that first parameter of window.open should also be enclosed using quotes.

Green Techy
A: 

onclick may not be the best event to attach that action to. Anytime anyone clicks anywhere in the form, it will open the window.

<form action="..." ...
    onsubmit="window.open('google.html', '_blank', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');return true;">
Grant Wagner