Java script can pass value from parent to pop up and also can pass value from pop up to parent. First thing that we do is make a Java script function in parent page . here is the simple example :
1. Make a page as parent page :
<html>
<head>
<title>Parent Page</title>
<script language="javascript">
//this function for getting value from popup
function GetValueFromChild(myVal)
{
document.getElementById('mytxt').value = myVal;
}
// this function for opening new window popup
function mypopup() {
window.open('mypopup.php','popup','width=150','height=100','toolbar=no','status=no');
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="test" method="post">
<input type="text" name="mytxt" id="mytxt">
<input type="button" name="mybut" onClick="cari()" value="popup">
</form>
</body>
</html>
save this as parent.php
then the second is you have to make a popup file that can be opened by parent.php
look the script below for popup.:
<html>
<head>
<title>Popup</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function SendValueToParent()
{
var myVal = document.getElementById('mytxt').value;
window.opener.GetValueFromChild(myVal);
window.close();
return false;
}
</script>
</head>
<body>
<form name="a" method="post">
<input type="text" name="myvar" id="mytxt">
<input type="button" name="mysub" value="Send" onClick="SendValueToParent()">
</form>
</body>
</html>
Save this script as mypopup.php.
the would be like the picture below :
from this example you may improve to other case like searching data and send it to parent form.
OK, thank see u..
download script
here
or
here to
Judul : Send variable value from popup to parent
Deskripsi : Java script can pass value from parent to pop up and also can pass value from pop up to parent. First thing that we do is make a Java script...