How can I mantain the OPENER state?
Posted: Fri Dec 29, 2006 11:10 am
Hi everyone
Even if I 'm a PHP programmer I'm a newbie in Javascript (shame on me
)
I allways C/P Javascript an this is my first "step" writing.
The problem
I create two pages that should be connected with javascript in this way.
The page 1.html contains two input text fields with the unique ID and a link that through javascript opens the page 2.php passing the ID of the text field I want to fill.
The file 2.php contains many values, onClick the send the selected value to 1.html and to the wright field.
This works fine if I make no action inside 2.php but if for example I do a POST or a link action inside 2.php the reference to 1.html and the field ID get lost.
How can I do to mantain those values even if I move around the 2.php page?
Am I taking the wrong road to success? LOL
is it a concept problem or procedure problem?
TNX for your time
1.html code
2.php code
Even if I 'm a PHP programmer I'm a newbie in Javascript (shame on me
I allways C/P Javascript an this is my first "step" writing.
The problem
I create two pages that should be connected with javascript in this way.
The page 1.html contains two input text fields with the unique ID and a link that through javascript opens the page 2.php passing the ID of the text field I want to fill.
The file 2.php contains many values, onClick the send the selected value to 1.html and to the wright field.
This works fine if I make no action inside 2.php but if for example I do a POST or a link action inside 2.php the reference to 1.html and the field ID get lost.
How can I do to mantain those values even if I move around the 2.php page?
Am I taking the wrong road to success? LOL
is it a concept problem or procedure problem?
TNX for your time
1.html code
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function open_tool(URL,field_identifier){
win2=window.open(URL,"","scrollbars=yes,width=700,height=500");
win2.creator=self;
win2.field_identifier=field_identifier;
}
//-->
</script>
</head>
<body>
<form action="" method="POST">
<input type="text" name="title" id="title" value=""><a href="javascript:open_tool('2.php','title');" >()</a><br>
<input type="text" name="color" id="color" value=""><a href="javascript:open_tool('2.php','color');" >()</a>
</form>
</body>
</html>Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function return_tool_selection(field_identifier_value){
window.opener.document.getElementById(field_identifier).value=field_identifier_value;
}
//-->
</script>
</head>
<body>
<ul>
<li><a href="<?php echo $_SERVER['PHP_SELF']."?listing=blue_line"; ?>">Blue Line</a></li>
<li><a href="<?php echo $_SERVER['PHP_SELF']."?listing=red_line"; ?>">Red Line</a></li>
</ul>
<table cellpadding="2" cellspacing="0" border="0" width="300">
<?php
if($_REQUEST['listing'] == "blue_line"){
?>
<tr>
<td colspan="2">
Blue line
</td>
</tr>
<tr>
<td bgcolor="#006388"> </td>
<td><a href="javascript:return_tool_selection('#006388');window.close();">#006388</a></td>
</tr>
<tr>
<td bgcolor="#0094CC"> </td>
<td><a href="javascript:return_tool_selection('#0094CC');window.close();">#0094CC</a></td>
</tr>
<tr>
<td bgcolor="#0DBCFF"> </td>
<td><a href="javascript:return_tool_selection('#0DBCFF');window.close();">#0DBCFF</a></td>
</tr>
<?php
}
elseif($_REQUEST['listing'] == "red_line"){
?>
<tr>
<td colspan="2">
Red Line
</td>
</tr>
<tr>
<td bgcolor="#7D0003"> </td>
<td><a href="javascript:return_tool_selection('#7D0003');window.close();">#7D0003</a></td>
</tr>
<tr>
<td bgcolor="#B00004"> </td>
<td><a href="javascript:return_tool_selection('#B00004');window.close();">#B00004</a></td>
</tr>
<tr>
<td bgcolor="#F00006"> </td>
<td><a href="javascript:return_tool_selection('#F00006');window.close();">#F00006</a></td>
</tr>
<?php
}
else{
echo "<tr>
<td colspan=\"2\">
Select a list
</td>
</tr>";
}
?>
</table>
<br><br><br><br>
<table cellpadding="2" cellspacing="0" border="0" width="300">
<tr>
<td colspan="2">
Fixed Line
</td>
</tr>
<tr>
<td bgcolor="#0C5900"> </td>
<td><a href="javascript:return_tool_selection('#0C5900');window.close();">#0C5900</a></td>
</tr>
<tr>
<td bgcolor="#118800"> </td>
<td><a href="javascript:return_tool_selection('#118800');window.close();">#118800</a></td>
</tr>
<tr>
<td bgcolor="#17B900"> </td>
<td><a href="javascript:return_tool_selection('#17B900');window.close();">#17B900</a></td>
</tr>
</table>
</body>
</html>