posted 23 years ago
This solution is all client-side.
The setTimeout("checkParms()",300) is needed for a timing problem in windows.Another way is to execute an alert("some msg") in the new window befoe accessing the properties set by the parent window.
Note:You have to remove the space from:
on click="getInfo.
<html>
<!--Example of how to reference
-javascript array object variable from parent window
-->
<head>
<script language=javascript>
aTableData = [ ["Cat" , "Food" , "Cat Food"] , ["Dog" , "Food" , "Dog Food"] ];
function getData(aData,iIndex){
var x;
for(x=0; x < aData[iIndex].length-1;x++) document.write( aData[iIndex][x] + " " );
}
var newWin = null;
function getInfo(aData,iRow,iCol){
if( newWin != null && newWin.closed == false ){ newWin.close(); }
newWin = window.open("getInfo.html","","width=350,height=250,top=90,left=200");
newWin.moveTo(200,90); //for non ie browsers add other attributes to the open if you prefer
newWin.iRow = iRow;
newWin.iCol = iCol;
newWin.aData = aData;
}
</script>
</head>
<body>
<table>
<tr>
<td>
<input type=button value="enter data" on click="getInfo(aTableData,0,2)">
</td>
<td>
<script>getData(aTableData,0)</script>
</td>
</tr>
<tr>
<td>
<input type=button value="enter data" on click="getInfo(aTableData,1,2)">
</td>
<td>
<script>getData(aTableData,1)</script>
</td>
</tr>
</table>
</body>
</html>
<!--
Contents of getInfo.html:
<html>
<head>
<script language=javascript>
function checkParms(){
alert(aData[iRow][iCol]);
}
function writeParms(){
document.form1.sent.value = aData[iRow][iCol];
}
</script>
</head>
<body >
<form name="form1">
<table>
<tr>
<td>
helpful info:
</td>
<td>
<input id="sent" type=text value="">
</td>
</tr>
<tr>
<td>
Enter Data:
</td>
<td>
<input id="data" type=text value="">
</td>
</tr>
<tr>
<td>
<input type=submit action="processForm.jsp" method=get value="Submit">
</td>
</tr>
</table>
</form>
</body>
<script language=javascript>
setTimeout("writeParms()",300);
</script>
</html>
-->
[ April 06, 2002: Message edited by: Charlie Sturman ]