posting hidden form data to a popup window

posting hidden form data to a popup window

Post by simor » Sun, 27 May 2007 18:26:28


Hi:
Need some working sample code to post hidden form data from a php page
to a new popup window. 540 x 500 centered. The popup that I'm calling
already is formatted and has a TITLE:web-2007.php so what I need to do
is to write the values from the PHP page to that popup in specific
places.

Some of the hidden values are also like this format;

<input type="hidden" name="handling" value="<?php echo $_POST["sub"];
?>">

<input type="hidden" name="email" value="<?php echo $_POST["email"];
?>">

Right now,the hidden input fields are on a PHP page, and I'm calling the
popup from the generated PHP page like so:

<A HREF="javascript:void(0);" style="TEXT-DECORATION: none"
onClick="popUpCenteredWindow();"> <span style="color: blue; font-
family: Verdana;"> Click Here   </span></span></A></font>

<script language="JavaScript">

function popUpCenteredWindow() {
var iMyWidth;
var iMyHeight;
//gets top and left positions .
iMyWidth = (window.screen.width/2) - (200 + 10);
//half the screen width etc..
iMyHeight = (window.screen.height/2) - (255 + 1);
//half the screen height etc...
var win2 = window.open("web-2007.php","Window2","status,height=
540,width=500,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight +
",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");
win2.focus();
}
</script>

Need help. Thanks
 
 
 

posting hidden form data to a popup window

Post by Erwin Moll » Sun, 27 May 2007 19:14:38


Hi,

This can be solved in different ways, depending on your needs/setup.
1) The easiest way is changing the url you use and expand it so it contains
(urlencoded) name/value pairs.
eg:

var theURL = "web-2007.php";
// get some hidden form info:
var firstname = document.forms.formnamehere.firstname.value;
theURL += "?firstname="+firstname;
theURL = encodeURI(theURL);

var win2 = window.open(theURL,"Window2","status,height=
540,width=500,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight +
",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",scrollbars=yes");

Then from the popup, read the URL, and get your name-value pairs out.

2) More complex: Make window-communication.
EG: On the popupwindow add an onLoad-eventhandler that calls a function that
loads info from the opener.
eg:
<body onLoad="loadHiddenInfo();">
...
<script type="text/javascript">
function loadHiddenInfo(){
var firstname = opener.document.forms.formnamehere.firstname.value;
alert (firstname);
}
</script>

3) Use a SUBMIT instead of a hyperlink. CHange the target of your form to
the name of the window you opened (it must be opened first by yourself if
you want to set dimension like width and height.).

Regards,
Erwin Moller

 
 
 

posting hidden form data to a popup window

Post by ma » Mon, 28 May 2007 08:46:06

Hi:

Thanks for the ideas, but I'm not well versed on the level of javascript
required. I'll need more sample code suited to my situation. On my
formatted PHP page, I'm set up to get vlues in this format;
<?php echo $_POST["salutation"]; ?>. 
<?php echo $_POST["first_name"]; ?> <?php echo $_POST["last_name"];
?><BR>
 <?php echo $_POST["address"]; ?><BR>

What I need to see is both how I can send the hidden values, and how do
I display them on the PHP popup page. I do not need an alert.

Is there some way to make sure that the popup is fully opened before I
start having it get the hidden values.?

=============================================

On Sat, 26 May 2007 03:14:38 -0700, Erwin Moller
< XXXX@XXXXX.COM > wrote:




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
 
 
 

posting hidden form data to a popup window

Post by Erwin Moll » Tue, 29 May 2007 17:08:54

a <al.qwest.net> wrote:


Hi,

I don't want to be rude: but I adressed those questions.
If you are not able to implement them, what do you want us to do?
Create the whole script without being able to see what you made already?

My suggestion: OR you learn a little JavaScript basics so you can implement
it yourself (it is really easy), OR you hire somebody who can help you with
it.
Sorry mate.

Regards,
Erwin Moller