Javascript - getElementsByName Home
Javascript - getElementsByName
20/01/2006 posted by Kevin S
heres a code frag - hope it helps. In the Stylesheet have:
.show { display:marker; }
.hide { display:none; }
In the Javascript have:
function hideSelects( val, item )
{
for( loop=0;loop<=item;loop++ )
{
var elem = document.getElementById( val+loop );
if( elem )
{
if( elem.className=="" || elem.className=="show")
{
elem.className = 'hide';
}
else
{
elem.className = 'show';
}
} /* if */
} /*for*/
}
and in the html:
<h1 onclick="hideSelects('row', 2)">clickme!</h1>
<table>
<tr id="row0">
<td>some text1</td>
</tr>
<tr id="row1">
<td>some text2</td>
</tr>
<tr id="row2">
<td>some text2</td>
</tr>
</table>
|