Jump to content


pass $_POST data into popup window

  • Please log in to reply
2 replies to this topic

#1 ktsirig

  • Members
  • PipPipPip
  • Advanced Member
  • 49 posts

Posted 18 April 2006 - 09:56 PM

Hi all!
I have a page (generated with PHP) that has a list of employee names. What I want to do is, when the user hits on each name, a pop-up window (using Javascript) to appear which will say some more details on the employee (i.e his age, job experience etc).
So I thought I make a form for each employee name, and use hidden fields to pass the info I want.
For example

<input type="hidden" name ="age" value="23 years old">
<input type="hidden" name="experience" value="expert">
<input type="submit" value="John">

With the above, I show a little example of course. What I have is a submit button with John's name written in it and I want, when the user clicks on John, a pop-up window to appear and contain the "hidden" values of age and experience in it.
I don't know much about Javascript, i tried usind the document.write function, but no luck. I can only "send" data to the next page that are written in an input field, but not data that are written in hidden fields...
Any thoughts?

#2 chronicx

  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 01 May 2006 - 02:04 AM

There are two things you can do if I understand correctly. Either use get instead of post in your <form> tag. what this does is it takes the variables being passed; age or experience and it slaps them onto the url like so:

[a href=\"http://www.site.com/page2.php?age=23\" target=\"_blank\"]http://www.site.com/page2.php?age=23[/a] years old&experience=expert

where page2 would be the popup page. then, to print those, simply call the variable in your php script like so:

John is $age and is a(n) $experience.

Option number two:

use the post method in your form and the variables will be kinda hidden. to access these ones, do the following:
$age = $_POST['age'];
$experience = $_POST['experience'];
John is $age and is a(n) $experience.

whereas in the single quotes of this: $_POST['']; you put whatever the name of the field thats getting posted is.

This is only my second post here, so I hope imnot too confusing. the examples should help atleast. And i hope I understood the question and answered it so you can learn and finish your project. enjoy!

#3 buceta

  • Members
  • PipPip
  • Member
  • 12 posts

Posted 01 May 2006 - 06:58 AM

An code test for you by me:

<form action="http://www.phpfreaks.com/" method="post" onSubmit="win=window.open('','janela','toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,width=860,height=600,left = 80,top = 40'); this.target='janela';">

<input type="submit" value="test submit">



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users