943,737 Members | Top Members by Rank

Ad:
Nov 8th, 2008
0

Button to send POST data

Expand Post »
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

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <input type="submit" name="buttonUnit" value="Add" onClick="window.open('add.php','Done','width=400, height=130')">
Similar Threads
Reputation Points: 38
Solved Threads: 0
Master Poster
veledrom is offline Offline
724 posts
since Apr 2008
Nov 10th, 2008
0

Re: Button to send POST data

Click to Expand / Collapse  Quote originally posted by veledrom ...
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

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <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.
Reputation Points: 10
Solved Threads: 3
Newbie Poster
sasankasekhar is offline Offline
24 posts
since Jan 2007
Nov 10th, 2008
0

Re: Button to send POST data

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.
Reputation Points: 38
Solved Threads: 0
Master Poster
veledrom is offline Offline
724 posts
since Apr 2008
Nov 10th, 2008
0

Re: Button to send POST data

Click to Expand / Collapse  Quote originally posted by veledrom ...
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['inp']; ?><br>
Get Value: <?php echo $_GET['datafrombasepage']; ?>
</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.
Last edited by sasankasekhar; Nov 10th, 2008 at 11:03 am.
Reputation Points: 10
Solved Threads: 3
Newbie Poster
sasankasekhar is offline Offline
24 posts
since Jan 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: JS variable inside HTML
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Form Validation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC