Solved

Add OnClick Event to a Form Action

Posted on 2012-03-28
1
223 Views
Last Modified: 2016-03-24
Is there a way to add an OnClick event to a form action?  When you click submit on my form it takes you to paypal, but I want it to open in a new window that I can set to a specific size.

Any Clues?  Thanks in advance Y'all!
0
Comment
Question by:rgranlund
1 Comment
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 300 total points
Comment Utility
Refer here:-
http://www.codebelt.com/jquery/open-new-browser-window-with-jquery-custom-size/

<script type="text/javascript">
    //Created an array to hold onto the desired info.
    var windowSizeArray = [ "width=200,height=200",
                            "width=300,height=400,scrollbars=yes" ];
 
    $(document).ready(function(){
        //Links that has the ".newWindow" class will call this script.
        $('.newWindow').click(function (event){
 
            // Gets the URL from the clicked link.
            var url = $(this).attr("href");
 
            /*Gets the name from the clicked link. Currently I commented out the
              jquery script and just put "popUp" for a default name because I didn't
              include the name in the links.*/
            var windowName = "popUp";//$(this).attr("name");
 
            /*Places the string from the array into the windowSize variable.
              The array slot is determined by the "rel" number on the link.*/
            var windowSize = windowSizeArray[  $(this).attr("rel")  ];
 
            //This method opens a new browser window.
            window.open(url, windowName, windowSize);
 
            /*Prevents the browser from executing the default action and
              allows us to use the "window.open" within our script.*/
            event.preventDefault();
 
        });
    });
</script>

Open in new window

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to dynamically set the form action using jQuery.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now