Forum Moderators: open

Message Too Old, No Replies

Submit Form to open a new window for analytics tracking

         

jackfitz

7:22 am on May 22, 2009 (gmt 0)

10+ Year Member



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://myurlatmailchimp.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

rocknbil

2:56 pm on May 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard jackfitz.

1. Quote your onclick="" attribute.

2. When placed in a form element, Javascript event handlers should receive return false or the main window will also submit to the url specified in action.

3. Never disable scrollbars, while aesthetics may seem to require it, you don't know your user's environment. Imagine content down below the border of the window you can't access; very frustrating. I see you leave resizable in there but many users don't know to resize a window.

4. When specifying a url of the window object, quote it, 'google.html', not bare google.html.

5. To not include window attributes, simply leave them off; you don't need to specify "yes" or "no" in the attributes.

6. Be sure to remove all newlines within the form tag of the following code, that is,

<form....>

is valid,

<form ....
>

Is not.

6. The label attribute is supposed to target the id of the form element; that is, <label for="some-element">... targets <input type="text" id="some-element">

Bolded changes below.

<form action="http://example.com" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" onclick="window.open('google.html','','scrollbars,height=600,width=800,resizable'); return false;">
<label for="mce-FNAME">Your Name</label><input type="text" value="" name="FNAME" class="required" id="mce-FNAME">
<br>
<br>
<label for="mce-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>