Button to send POST data

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Apr 2008
Posts: 497
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training

Button to send POST data

 
0
  #1
Nov 8th, 2008
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')">
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 24
Reputation: sasankasekhar is an unknown quantity at this point 
Solved Threads: 3
sasankasekhar's Avatar
sasankasekhar sasankasekhar is offline Offline
Newbie Poster

Re: Button to send POST data

 
0
  #2
Nov 10th, 2008
Originally Posted by veledrom View 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')">

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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 497
Reputation: veledrom is an unknown quantity at this point 
Solved Threads: 0
veledrom veledrom is offline Offline
Posting Pro in Training

Re: Button to send POST data

 
0
  #3
Nov 10th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 24
Reputation: sasankasekhar is an unknown quantity at this point 
Solved Threads: 3
sasankasekhar's Avatar
sasankasekhar sasankasekhar is offline Offline
Newbie Poster

Re: Button to send POST data

 
0
  #4
Nov 10th, 2008
Originally Posted by veledrom View Post
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.
IF SOMEONE FEELS THAT THEY HAD NEVER MADE A MISTAKE IN THEIR LIFE, THEN  IT MEANS THEY HAD NEVER TRIED A NEW THING IN THEIR LIFE
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC