So, I am a beginner at HTML, and was wondering if it is possible to do what I am trying to do below. It is crashing, but I’m not sure if the only reason is my syntax, or if it is not possible at all.
The declaration of the function:
<!-- Copyright 2005, Sandeep Gangadharan -->
<!-- For more free scripts go to http://www.sivamdesign.com/scripts/ -->
if (document.getElementById) {
document.writeln('<style type="text/css"><!--')
document.writeln('.texter {display:none} @media print {.texter {display:block;}}')
document.writeln('//--></style>') }
function close(theID) {
if (document.getElementById(theID).style.display == "block") { document.getElementById(theID).style.display = "none" } }
function open(theID) {
if (document.getElementById(theID).style.display == "block") { document.getElementById(theID).style.display = "none" }
else { document.getElementById(theID).style.display = "block" } }
// -->
</script>
</head>
Use of the function:
<table>
<tbody>
<tr>
<td colspan="2" rowspan="0">
<div>• <a href="/tallwalls/" target="_blank"><b>Tall Walls Sizer</b></a></div>
<p onClick="open('a4'), close('a1','a2','a3')" style="cursor:hand; cursor:pointer">
<span style="color: #808080;">[Click here for more information]</span></p>
</td>
</tr>
<tr id="a4" class="texter">
<td style="padding:0px;width:210px;"><a href="/tallwalls/" target="_blank" title="Tall Walls Sizer"><img src="/images/logos/tallWALLS.gif" alt="" width="206" height="41"/></a></td>
<td>
<div>DESCRIPTION</div>
</td>
</tr>
</tbody>
</table>
Mainly the onClick=”open(‘a4’), close(‘a1′,’a2′,’a3’)” is where I am not sure if this is proper syntax.
EDIT: Forgot to mention, that the other ids do exist. They are composed of this same pattern x4
Thanks in advance,
SirKaydian
Javascript lines end in ; so you need to first use
open('a4');Also, you have only defined close() for one argument, so you need to split
close('a1','a2','a3')intoclose('a1'); close('a2'); close('a3');If you’re new to HTML I would suggest a little bit of reading on jQuery. Its hide() and show() methods will make what you are trying to do very easy.