Hi,

Button below opens new popup window but doesn't send POST data from form. How can i send POST data? I know "form action" but, i want this way.

Thanks

<input type="submit" name="buttonUnit" value="Add" onClick="window.open('add.php','Done','width=400, height=130')">

Hi,

Button below opens new popup window but doesn't send POST data from form. How can i send POST data? I know "form action" but, i want this way.

Thanks

<input type="submit" name="buttonUnit" value="Add" onClick="window.open('add.php','Done','width=400, height=130')">

Just to be clear: Do you want to post your data from the current form to add.php?

if the answer is YES, try this:
-------------------------------------------------------------------------------
<form action="add.php" onSubmit="window.open('','Done','width=400, height=130')">
<input type="submit" name="buttonUnit" value="Add">
...... etc
</form>
-------------------------------------------------------------------------------


OR
-------------------------------------------------------------------------------
<script language='JavaScript'>
function postMyForm(){
document.forms[0].action="add.php";
window.open('','Done','width=400, height=130');
}
</script>
<input type="submit" name="buttonUnit" value="Add" onClick="postMyForm();">
-------------------------------------------------------------------------------
Hope this works.

Answer is YES.
When i click on ADD button, it is going to open a popup windows (add.php) with POST data. The page has ADD button will remain same in the background. Your code opens popup without POST data and other page changes.

Answer is YES.
When i click on ADD button, it is going to open a popup windows (add.php) with POST data. The page has ADD button will remain same in the background. Your code opens popup without POST data and other page changes.

Well, to post Data from one window to another we shall have to take the help of <iframe> (this is what I feel comfortable with).
The solution below may not be exactly what you wanted/ needed ... I am sure you will get your answer.
For this I create 3 files viz. index.php(the Base Page), add.php and an intermediate page framePage.php.

Code for index.php:
<body>
<form action="add.php" method="post" target="newForm" onSubmit="window.open('framePage.php','Done','width=400, height=130')">
<input type="input" name="inp" value="Posted Data"><br>
<input type="submit" name="buttonUnit" value="Add [For Post]">
...... etc<br>
<br>
<input type="button" name="button2" value="Add [For Get]" onClick = "window.open('add.php?datafrombasepage=GetData','Done','width=400, height=130')">
You will not get Post values using this.
</form>
</body>

Code for add.php:
<body>
Post Value: <?php echo $_POST; ?><br>
Get Value: <?php echo $_GET; ?>
</body>

Code for framePage.php:
<body>
<iframe name="newForm" src="add.php"></iframe>
</body>

the main points involved in posting data from one window to another are :<form target="newForm" (..name of the frame where to post data)>
AND
<iframe name="newform">

Hope you find your answer here. Sorry for the mistake in the previous reply.

Regards,
Sasanka.

This article has been dead for over six months. Start a new discussion instead.