how can i refer a dynamically created table named 'listTable2' from a new opened window named 'win' using the function moveToElementText() function?...i will put the table in Excel...I can refer with 'listTable' but not with 'listTable2'...below are the codes...
Pls help me!...i need the answer immediately...THANXS!
<html>
<head>
<title>Printing With Excel</title>
</head>
<body bgcolor="#FFFFFF">
<form>
<table name="listTable" id="listTable" width="98%" border="0">
<tr>
<td colspan="3">
<div align="center"><b>MAINTAIN CLIENT</b></div>
</td>
</tr>
<tr>
<td width="14%"> </td>
<td width="62%"> </td>
<td width="24%"> </td>
</tr>
<tr>
<td width="14%"><b>Client No.</b></td>
<td width="62%"><b>
<input type="text" name="text1" size="15">
</b></td>
<td width="24%"><b> </b></td>
</tr>
<tr>
<td width="14%"><b>Client Name</b></td>
<td width="62%"><b>
<input type="text" name="text2" size="40">
</b></td>
</tr>
</table>
<input type=button value=Print onClick="rewrite(this.form)">
</form>
<script language="javascript">
function rewrite(a){
win=window.open('','win','width=500,height=300,statusbar=0,menubar=0,title=0,status=0')
win.document.writeln('<html><head><title></title></head>')
win.document.writeln('<body bgcolor=white>')
win.document.writeln('<font color=red></font>')
win.document.writeln('<form name="f">')
win.document.writeln('<table name="listTable2" id="listTable2" width="98%" border="0">')
win.document.writeln('<tr>')
win.document.writeln('<td colspan="3">')
win.document.writeln('<div align="center"><b>MAINTAIN CLIENT</b></div>')
win.document.writeln('</td>')
win.document.writeln('</tr>')
win.document.writeln('<tr>')
win.document.writeln('<td width="25%"><b>Client No.:</b></td>')
win.document.writeln('<td width="70%"><b>')
win.document.writeln(a.text1.value)
win.document.writeln('</b></td>')
win.document.writeln('<td width="24%"><b> </b></td>')
win.document.writeln('</tr>')
win.document.writeln('<tr>')
win.document.writeln('<td width="25%"><b>Client Name:</b></td>')
win.document.writeln('<td width="70%"><b>')
win.document.writeln(a.text2.value)
win.document.writeln('</b></td>')
win.document.writeln('</tr>')
win.document.writeln('</table>')
win.document.writeln('</form>')
win.document.writeln('</body></html>')
textRange = document.body.createTextRange();
textRange.moveToElementText(listTable);
textRange.execCommand("Copy"
window.open('outputFile.xls','printing');
}
</script>
</body>
</html>
Pls help me!...i need the answer immediately...THANXS!
<html>
<head>
<title>Printing With Excel</title>
</head>
<body bgcolor="#FFFFFF">
<form>
<table name="listTable" id="listTable" width="98%" border="0">
<tr>
<td colspan="3">
<div align="center"><b>MAINTAIN CLIENT</b></div>
</td>
</tr>
<tr>
<td width="14%"> </td>
<td width="62%"> </td>
<td width="24%"> </td>
</tr>
<tr>
<td width="14%"><b>Client No.</b></td>
<td width="62%"><b>
<input type="text" name="text1" size="15">
</b></td>
<td width="24%"><b> </b></td>
</tr>
<tr>
<td width="14%"><b>Client Name</b></td>
<td width="62%"><b>
<input type="text" name="text2" size="40">
</b></td>
</tr>
</table>
<input type=button value=Print onClick="rewrite(this.form)">
</form>
<script language="javascript">
function rewrite(a){
win=window.open('','win','width=500,height=300,statusbar=0,menubar=0,title=0,status=0')
win.document.writeln('<html><head><title></title></head>')
win.document.writeln('<body bgcolor=white>')
win.document.writeln('<font color=red></font>')
win.document.writeln('<form name="f">')
win.document.writeln('<table name="listTable2" id="listTable2" width="98%" border="0">')
win.document.writeln('<tr>')
win.document.writeln('<td colspan="3">')
win.document.writeln('<div align="center"><b>MAINTAIN CLIENT</b></div>')
win.document.writeln('</td>')
win.document.writeln('</tr>')
win.document.writeln('<tr>')
win.document.writeln('<td width="25%"><b>Client No.:</b></td>')
win.document.writeln('<td width="70%"><b>')
win.document.writeln(a.text1.value)
win.document.writeln('</b></td>')
win.document.writeln('<td width="24%"><b> </b></td>')
win.document.writeln('</tr>')
win.document.writeln('<tr>')
win.document.writeln('<td width="25%"><b>Client Name:</b></td>')
win.document.writeln('<td width="70%"><b>')
win.document.writeln(a.text2.value)
win.document.writeln('</b></td>')
win.document.writeln('</tr>')
win.document.writeln('</table>')
win.document.writeln('</form>')
win.document.writeln('</body></html>')
textRange = document.body.createTextRange();
textRange.moveToElementText(listTable);
textRange.execCommand("Copy"
window.open('outputFile.xls','printing');
}
</script>
</body>
</html>