ktsirig Posted April 18, 2006 Share Posted April 18, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/7779-pass-_post-data-into-popup-window/ Share on other sites More sharing options...
chronicx Posted May 1, 2006 Share Posted May 1, 2006 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=expertwhere page2 would be the popup page. then, to print those, simply call the variable in your php script like so:[code]<?phpprint("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! Quote Link to comment https://forums.phpfreaks.com/topic/7779-pass-_post-data-into-popup-window/#findComment-32275 Share on other sites More sharing options...
buceta Posted May 1, 2006 Share Posted May 1, 2006 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];) Quote Link to comment https://forums.phpfreaks.com/topic/7779-pass-_post-data-into-popup-window/#findComment-32307 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.