Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help in outputting value of a textfield within a table

Status
Not open for further replies.

miks

MIS
Sep 27, 2002
13
0
0
CH
Hi guys! My problem is how to output the value of a 'text1' in table 'listTable' to a cell in table 'listTable2'. Is there a way in JavaScript to do this? Here is the code fragments...



<html>
<head>
<title>Printing With Excel</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot;>
<form name=&quot;a&quot;>
<table name=&quot;listTable&quot; id=&quot;listTable&quot; width=&quot;98%&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;3&quot;>
<div align=&quot;center&quot;><b>MAINTAIN CLIENT</b></div>
</td>
</tr>
<tr>
<td width=&quot;14%&quot;></td>
<td width=&quot;62%&quot;></td>
<td width=&quot;24%&quot;></td>
</tr>
<tr>
<td width=&quot;14%&quot;><b>Client No.</b></td>
<td width=&quot;62%&quot;><b>
<input type=&quot;text&quot; name=&quot;text1&quot; size=&quot;15&quot;>
</b></td>
<td width=&quot;24%&quot;><b> </b></td>
</tr>
<tr>
<td width=&quot;14%&quot;><b>Client Name</b></td>
<td width=&quot;62%&quot;><b>
<input type=&quot;text&quot; name=&quot;text2&quot; size=&quot;40&quot;>
</b></td>
</tr>
</table>

<table name=&quot;listTable2&quot; id=&quot;listTable2&quot; width=&quot;98%&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;3&quot;>
<div align=&quot;center&quot;><b>MAINTAIN CLIENT</b></div>
</td>
</tr>
<tr>
<td width=&quot;14%&quot;></td>
<td width=&quot;62%&quot;></td>
<td width=&quot;24%&quot;></td>
</tr>
<tr>
<td width=&quot;14%&quot;><b>Client No.</b></td>
<td width=&quot;62%&quot;><b>
<td> document.a.listTable.text1.value </td>
<!input type=&quot;text&quot; name=&quot;text1&quot; size=&quot;15&quot;>
</b></td>
<td width=&quot;24%&quot;><b> </b></td>
</tr>
<tr>
<td width=&quot;14%&quot;><b>Client Name</b></td>
<td width=&quot;62%&quot;><b>
<input type=&quot;text&quot; name=&quot;text2&quot; size=&quot;40&quot;>
</b></td>
</tr>
</table>

<input type=button value=Print onClick=&quot;rewrite(this.form)&quot;>
</form>

 
browsers compability required?
(ie4+ nn4+ etc or just ie or just nn?)
 
if u just want IE this will do it. I think its what your looking for. If you want cross browser stuff youll need to alter the writeTo function as well as the variable refernecing..

Code:
<html>
<head>
<title>Printing With Excel</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<script language=&quot;JavaScript&quot;>
<!--//
function rewrite()
{
var myString=document.a.text1.value;
writeTo('myDiv',myString);
}

function writeTo(divID,divText)
{
document.getElementById(divID).innerHTML=divText;
}
//-->
</script>


</head>
<body bgcolor=&quot;#FFFFFF&quot;>
<form name=&quot;a&quot;>
<table name=&quot;listTable&quot; id=&quot;listTable&quot; width=&quot;98%&quot; border=&quot;0&quot;>
  <tr> 
    <td colspan=&quot;3&quot;> 
      <div align=&quot;center&quot;><b>MAINTAIN CLIENT</b></div>
    </td>
  </tr>
  <tr>
    <td width=&quot;14%&quot;></td>
    <td width=&quot;62%&quot;></td>
    <td width=&quot;24%&quot;></td>
  </tr>
  <tr> 
    <td width=&quot;14%&quot;><b>Client No.</b></td>
    <td width=&quot;62%&quot;><b> 
      <input type=&quot;text&quot; name=&quot;text1&quot; size=&quot;15&quot;>
      </b></td>
    <td width=&quot;24%&quot;><b> </b></td>
  </tr>
  <tr> 
    <td width=&quot;14%&quot;><b>Client Name</b></td>
    <td width=&quot;62%&quot;><b> 
      <input type=&quot;text&quot; name=&quot;text2&quot; size=&quot;40&quot;>
      </b></td>
    </tr>
</table>

<table name=&quot;listTable2&quot; id=&quot;listTable2&quot; width=&quot;98%&quot; border=&quot;0&quot;>
  <tr> 
    <td colspan=&quot;3&quot;> 
      <div align=&quot;center&quot;><b>MAINTAIN CLIENT</b></div>
    </td>
  </tr>
  <tr>
    <td width=&quot;14%&quot;></td>
    <td width=&quot;62%&quot;></td>
    <td width=&quot;24%&quot;></td>
  </tr>
  <tr> 
    <td width=&quot;14%&quot;><b>Client No.</b></td>
    <td width=&quot;62%&quot;><b> 
       <td><div id=&quot;myDiv&quot;></div></td>
      <!input type=&quot;text&quot; name=&quot;text1&quot; size=&quot;15&quot;>
      </b></td>
    <td width=&quot;24%&quot;><b> </b></td>
  </tr>
  <tr> 
    <td width=&quot;14%&quot;><b>Client Name</b></td>
    <td width=&quot;62%&quot;><b> 
      <input type=&quot;text&quot; name=&quot;text2&quot; size=&quot;40&quot;>
      </b></td>
    </tr>
</table>

<input type=button value=Print onClick=&quot;rewrite()&quot;>
</form>
</body>
</html>
hope this helps

rob
 
oh if u want it to work in IE4 itll need changing the above is for ie5+ but its a start
:)
 
well, here is the simple code, if it is what u're for, lemme kno..
<span id=daOne style=&quot;position:absolute&quot;></span>-relative if u want 2 put it into the table

ie4x:
if (document.all)
document.all.daOne.innerHTML='new content'
ie5x, nn6:
if (document.getElementById) document.getElementById(&quot;daOne&quot;).innerHTML='new content'
nn4x:
if(document.layers){
with (document.layers.daOne.document){
open()
write('new content')
close()
}
}


regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top