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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help in preventing output text from displaying in the browser

Status
Not open for further replies.

miks

MIS
Sep 27, 2002
13
CH
Hi guys! I cant figure out how to prevent the output of table 'listTable2' from displaying in the browser. Hidden field is not working. Maybe you can help :)

<html>
<head>
<title>Printing With Excel</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<script language=&quot;javascript&quot;>
function rewrite2(value)
{
document.all.needed.innerHTML=value
}
function rewrite3(value)
{
document.all.needed2.innerHTML=value
}

</script>
<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>
</tr>
<tr>
</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; onchange=&quot;rewrite2(this.value)&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; onchange=&quot;rewrite3(this.value)&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><!/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></b></td>
<td width=&quot;62%&quot;><!b>
<span id=&quot;needed&quot;><input type=&quot;hidden&quot; name=&quot;hidden1&quot; value=document.a.listTable.text1.value></span>
<!font color=&quot;#FFFFFF&quot;><!span id=&quot;needed&quot;><!document.a.listTable.text1.value></span></font>
</b></td>
<td width=&quot;24%&quot;><b></b></td>
</tr>
<tr>
<td width=&quot;14%&quot;><b></b></td>
<td width=&quot;62%&quot;><!b>
<span id=&quot;needed2&quot;><input type=&quot;hidden&quot; name=&quot;hidden2&quot; value=document.a.listTable.text2.value></span>
<!font color=&quot;#FFFFFF&quot;><!span id=&quot;needed2&quot;><!document.a.listTable.text2.value></span></font>
</b></td>
</tr>
</table>
<input type=button value=Print onClick=&quot;rewrite(this.form)&quot;>
</form>


<script language=&quot;javascript&quot;>

function rewrite(a){
//win=window.open('','win','width=5,height=5,statusbar=0,menubar=0,title=0,status=0');
//this.window.document.writeln('<html><head><title></title></head>')
//this.window.document.writeln('<body bgcolor=white>')
//win.document.writeln('<font color=red></font>')
//win.document.writeln('<form name=&quot;f&quot;>')
//win.document.writeln('<table name=&quot;listTable2&quot; id=&quot;listTable2&quot; width=&quot;98%&quot; border=&quot;0&quot;>')
//win.document.writeln('<tr>')
//win.document.writeln('<td colspan=&quot;3&quot;>')
//win.document.writeln('<div align=&quot;center&quot;><b>MAINTAIN CLIENT</b></div>')
//win.document.writeln('</td>')
//win.document.writeln('</tr>')
//win.document.writeln('<tr>')
//win.document.writeln('<td width=&quot;25%&quot;><b>Client No.:</b></td>')
//win.document.writeln('<td width=&quot;70%&quot;><b>')
//win.document.writeln(a.text1.value)
//win.document.writeln('</b></td>')
//win.document.writeln('<td width=&quot;24%&quot;><b> </b></td>')
//win.document.writeln('</tr>')
//win.document.writeln('<tr>')
//win.document.writeln('<td width=&quot;25%&quot;><b>Client Name:</b></td>')
//win.document.writeln('<td width=&quot;70%&quot;><b>')
//win.document.writeln(a.text2.value)
//win.document.writeln('</b></td>')
//win.document.writeln('</tr>')
//win.document.writeln('</table>')
//win.document.writeln('</form>')


//this.window.document.writeln('<font color=&quot;BLACK&quot;><span id=&quot;needed&quot;><document.a.listTable.text1.value></span></font>')
//this.window.document.writeln('<font color=&quot;BLACK&quot;><span id=&quot;needed2&quot;>document.a.listTable.text1.value</span></font>')
//this.window.document.writeln('</body></html>')



textRange = document.body.createTextRange();
textRange.moveToElementText(listTable2);
textRange.execCommand(&quot;Copy&quot;);
window.open('outputExcel.xls','printing');
}
</script>
</body>
</html>

 
hie
if u want 2 pass text1.value (& text2 though) into the hidden field, u shuld rewite ur function;
u c, when u're usin innerHTML property, u're rewritin the content of that layer; so, since u used it, there is no more hidden field, but just what u puted there (e.g. text1.value)
so, if u want just 2 set hidden field's value, use the followin code:
<html>
<head>
<title>settin hiden fields</title>
</head>
<script language=&quot;javascript&quot;>
function rewrite2(field){
var obj
if (field.name.substr(0,1)=='1')
obj= document.a.hidden1
else if (field.name.substr(0,1)=='2')
obj=document.a.hidden2
obj.value=field.value
}

function showHiddenValues(){
alert(document.a.hidden1.value+' '+document.a.hidden2.value)
}
</script>
<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>
</tr>
<tr>
</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;1text&quot; size=&quot;15&quot; onchange=&quot;rewrite2(this)&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;2text&quot; size=&quot;40&quot; onchange=&quot;rewrite2(this)&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><!/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></b></td>
<td width=&quot;62%&quot;><input type=&quot;hidden&quot; name=&quot;hidden1&quot; ></td>
<td width=&quot;24%&quot;><b></b></td>
</tr>
<tr>
<td width=&quot;14%&quot;><b></b></td>
<td width=&quot;62%&quot;><input type=&quot;hidden&quot; name=&quot;hidden2&quot; ></td>
</tr>
</table>
<input type=button value=Print onClick=&quot;showHiddenValues()&quot;>
</form>
</body>
</html>
[/green] regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top