Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes pass multiple fields to newWindow Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "pass multiple fields to newWindow" Watch "pass multiple fields to newWindow" New topic
Author

pass multiple fields to newWindow

rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
Hi
To make this short this is what I need to do. I have an undertermined amount of rows coming from a database into a html table. Each item in a recordSet populates a textField on the html table. So it looks like this.....
<tr bgcolor="#FFFFFF">
<td width="5%" align="center" valign="middle"><a href="javascript:makeNewWindow()"><img src="pics/smallButton.gif" width="8" height="8" border="0"></a></td>
<td width="4%"><font size="-3">
<input type="text" name="ent" value="<%=ent.trim()%>" maxlength="5" size="5" onFocus='this.blur()' readonly>
</font></td>
There are a lot more items in the row but no need to put them all here.
I need to do this. When a user clicks on a row I need to pass that data to a new window with extra text fields so a user can enter information about the charge into it. I'm not sure how to do this using javaScript but from what i know i think that javaScript is the best way to do this.
Can someone help me out?
Brian Glodde
Ranch Hand

Joined: Jun 27, 2001
Posts: 171
Since they're clicking on the link, we're left with one option, send the data, as an argument, to the javascript call like this:

You'll be able to pass all the data from that row to the window create function, which can then be appended to the url you're calling:
somefile.jsp?var1=foo&var2=bar&var3=java
Then it can be retrieved on somefile.jsp through getParameter() or getQueryString().
swaroop shastri
Ranch Hand

Joined: Aug 15, 2001
Posts: 65
<tr bgcolor="#FFFFFF">
<td width="5%" align="center" valign="middle"><a href="javascript:makeNewWindow(hiddenConcatedObj1)"><img src="pics/smallButton.gif" width="8" height="8" border="0"></a></td>
<td width="4%"><font size="-3">
<input type="text" name="ent1" value="<%=ent.trim()%>" maxlength="5" size="5" onFocus='this.blur()' readonly>
<input type="hidden" name="hiddenConcatedObj1" value="Concated values of the rest of the columns" >
</font></td>

Hope this might solve your problem. Notice the naming of hiddenConcatedObjxx with the row number as suffix. Let the makeNewWindow function decipher the hiddenobj value and put in text fields appropriately in the new window.
rich werth
Ranch Hand

Joined: Sep 21, 2001
Posts: 57
Hey thanks for your replies. It looks like I can take those ideas and put em to use.
Charlie Sturman
Ranch Hand

Joined: Apr 04, 2002
Posts: 112
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pass multiple fields to newWindow