2

Hi i have a form on my page, in asp.net, my form is hidden, it open in lightbox on click of a link on the page.

lightbox has a div with HTML form POST method and action to some URL, on click of submit button inside the form i am redirect to the action passed above, but i want to redirect on new window instead of same window. How can i achieve this. not i cannot change the action and form Post method since it is third party HTML for some functionality. If i change the Form HTML my functionality does not work.

If possible i can try to change my question please let me know.. if you need something more than this information...

Sameera Thilakasiri
  • 9,452
  • 10
  • 51
  • 86
Murtaza
  • 3,045
  • 2
  • 25
  • 39
  • Am i asking a wrong question, do we have any such way to do... waiting for reply... – Murtaza Jan 13 '12 at 06:40
  • I do not think this is a good idea that when a person presses the submit button the result is in another window/tab. It makes the UI confusing and will lead the person pressing the submit button multiple times. – Ed Heal Jan 13 '12 at 08:53
  • hi @Ed Heal since my form is in lightBox and i have created a converter which displays result in another window, therefore, UI is not the issue for me.. – Murtaza Jan 13 '12 at 09:03

2 Answers2

2

Try this example,

  <form action="form_action.asp" method="post" target="_blank"> 

Add the attribute target="_blank"

Sameera Thilakasiri
  • 9,452
  • 10
  • 51
  • 86
  • I tried this long time back but it is not working, POST method when open in new window does not get values from Previous Page. as it is new, my page is empty without the results... – Murtaza Jan 13 '12 at 09:05
  • ya it works but in my current flow it is not working, anyways this is the only solution i have found from past 8 hours.. – Murtaza Jan 13 '12 at 09:36
0

I don't why Sameera Thilakasiri's solution is not working. But please try this:

First please refer to this page: JavaScript post request like a form submit

You can do form submission with form object. If you can get the current values of forms and assign it to new form you are creating, it might work. Of course you should add the function name

function post_to_url(path, params, method) {
    method = method || "post"; 

     var form = document.createElement("form");
        form.setAttribute("method", method);
        form.setAttribute("action", path);
        form.setAttribute("target", "_blank");
    ...

        document.body.appendChild(form);
        form.submit();
        return false;
}

And change

<form action="form_action.asp" method="post" target="_blank" onsubmit="javascript:post_to_url(path, params, method)"> 
Community
  • 1
  • 1
batbaatar
  • 5,448
  • 2
  • 20
  • 26