Submit Form In Popup

[Total: 0    Average: 0/5]

Passing form data to another page and have it do the submit.

Body Code:

<script>
var _newWin=null;
function openIt(_form)
{
  var _options=""; /* define some if you want to */
  _newWin=window.open("","",_options);
  _newWin.document.open();
  var _s ="";
      _s+="<html><body>";
  _s+="This page has three hidden state data variables that were passed to it from the original window. As soon as the page loads, it submits its data so that the original window does not have to do the form submitting - but this popup does - now this window can be closed by the form action page if it wants to";
  _s+="<form method=get name=f1 action='http://www.js-examples.com/'>";
  _s+="<input type=hidden name=x1 value='"+_form.x1.value+"'>";
  _s+="<input type=hidden name=x2 value='"+_form.x2.value+"'>";
  _s+="<input type=hidden name=x3 value='"+_form.x3.value+"'>";
  _s+="<"+"script>";
  _s+="document.write('TEST');";
  _s+="document.f1.submit();";
  _s+="</"+"script>";
  _s+="</form>";
  _s+="</body></html>";
  _newWin.document.write(_s);
  _newWin.document.close();
}
</script>
<form method=get>
<input type=hidden name=x1 value="one">
<input type=hidden name=x2 value="two">
<input type=hidden name=x3 value="three">
<br>
<input value="PASS STATE DATA" type=button onclick="openIt(this.form)">
</form>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *