• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

pass multiple fields to newWindow

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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().
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey thanks for your replies. It looks like I can take those ideas and put em to use.
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic