Forum Moderators: open
The thing is, I just get the ever loving Object does not support this property or method error.. Where am I going wrong?
<script type="text/javascript">
<!-- //
function printthis(which) {
document.getElementByTagName('div').style.display = 'none';
document.getElementById(which).style.display = 'block';
window.print();
document.getElementByTagName("div").style.display = 'block';
}
//-->
</script>
<a href="javascript:void printthis('Week28');">Print</a>
<div id="Week28" style="display: block">Mooo</div>
<div id="Week29" style="display: block">Bahhh</div>
<div id="Week30" style="display: block">Bahhh</div>
it is >document.getElementsByTagName< Notice it is Elements, not Element.
Then I just had to go throught all the elements :)
<script language="javascript1.2">
function printthis(which) {
var tds = document.getElementsByTagName("div");
for(i=0;i<tds.length;i++)
tds.item(i).style.display = "none";
document.getElementById(which).style.display = "block";
window.print();
for(i=0;i<tds.length;i++)
tds.item(i).style.display = "block";
}
</script>
<input type="button" onclick="printthis('Week32')" value="CLICK Me">
<div id="Week32">OINK</div>
<div id="Week32">Cluck</div>
Does the geek victory dance :)