Click to See Complete Forum and Search --> : pass $_POST data into popup window


ktsirig
04-18-2006, 06:53 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

<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?

bpat1434
04-18-2006, 08:43 PM
This seems to work:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript" language="JavaScript">
<!--
function popWindow(wName){
features = 'width=400,height=400,toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no';
pop = window.open('',wName,features);
if(pop.focus){ pop.focus(); }
return true;
}
-->
</script>
</head>

<body>
<form action="js_pop.php" method="post" target="Details" onSubmit="return popWindow(this.target)">
<input type="hidden" name ="age" value="23 years old">
<input type="hidden" name="experience" value="expert">
<input type="submit" value="John">
</form>
<form action="js_pop.php" method="post" target="Details" onSubmit="return popWindow(this.target)">
<input type="hidden" name ="age" value="26 years old">
<input type="hidden" name="experience" value="novice">
<input type="submit" value="James">
</form>
<form action="js_pop.php" method="post" target="Details" onSubmit="return popWindow(this.target)">
<input type="hidden" name ="age" value="21 years old">
<input type="hidden" name="experience" value="intermediate">
<input type="submit" value="Jack">
</form>
</body>
</html>

js_pop.php
<?php
echo '<pre>';
var_dump($_POST);
echo '</pre>';
?>

ktsirig
04-19-2006, 06:55 PM
excellent post!!!
I think you hit exactly what I needed! Thank you so much for your time!