Jump to content

pass $_POST data into popup window


ktsirig

Recommended Posts

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

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

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?
Link to comment
Share on other sites

  • 2 weeks later...
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:

[code]<?php
print("
John is $age and is a(n) $experience.
");
?>
[/code]

Option number two:

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

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!

Link to comment
Share on other sites

An code test for you by me:

[code]<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">

</form>[/code]

;)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.