Organizational Research By

Surprising Reserch Topic

javascript post on form submit open a new window


javascript post on form submit open a new window  using -'javascript,html,post'

http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit shows you how to submit a form that you create via JavaScript via post. Below is my modified code.

var form = document.createElement("form");
            form.setAttribute("method", "post");
            form.setAttribute("action", "test.jsp");

                var hiddenField = document.createElement("input");       
                hiddenField.setAttribute("name", "id");
                hiddenField.setAttribute("value", "bob");
                form.appendChild(hiddenField);
                document.body.appendChild(form);    // Not entirely sure if this is necessary           
                form.submit();


What I would like to do is open the results in a new window. I am currentley using something like this to open a page in a new window:

onclick=window.open(test.html,'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,status=no');

    
asked Oct 19, 2015 by amit.gupta
0 votes
1 view



Related Hot Questions



Government Jobs Opening

Works!

answered Oct 19, 2015 by r3tt
0 votes

I worked on this all day and reading this page helped solve my issue. I was trying to get php to send a new page to the current page AND open a new page and present paypal to the user. Here is what I finally came up with:

/** This is the script that will redraw current screen and submit to paypal. */
echo ''."\n" ;

/** This form will be opened in a new window called PayPalPayment. */
echo 'https://www.sandbox.paypal.com/cgi-bin/webscr" name="paypal_form" method="post" target="PayPalPayment">'."\n" ;
echo ''."\n" ;
echo ''."\n" ;
echo ''."\n" ;
echo ''."\n" ;
echo '    '."\n";
echo '        '."\n" ;
echo '    '."\n" ;
echo '    '."\n" ;
echo '        '."\n" ;
echo '    '."\n" ;
echo '
Local
'."\n" ; echo ' '.$single_product->short_desc.' $'.$adj_price.' USD'."\n" ; // echo '
'."\n" ; echo ''."\n" ; echo ''."\n" ; /** This form will redraw the current page for approval. */ echo '
'."\n" ; echo ''."\n" ; echo ''."\n" ; echo '
'."\n" ; /** No form here just an input and a button. onClick will handle all the forms */ echo 'https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" alt="PayPal - The safer, easier way to pay online!" onclick="serverNotifySelected()">'."\n" ; echo 'https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">'."\n" ;

The code above is for just one button on the page. When that button is pressed, the screen changes to a pre-approval screen and at the same time another window is opened and gains focus. The new window with focus then get's taken over by PayPal.

answered Oct 19, 2015 by badhwar.rohit

...