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

Toggling an element - type mismatch

Status
Not open for further replies.

ArcoTorcido

Technical User
Aug 29, 2008
1
US
I've seen other posts in regard to Type Mismatches, but unfortunately I don't have the brainpower or experience to apply them to my code.

I have a series of tables whose visibility I would like to toggle. I'm trying to use a global variable (also used in other functions) to determine which table is visible.
Here is a simplified version:

<HEAD>
<script type="text/javascript">
var globalVar="dudeTable"

function showTable ()
{
document.getElementsById('globalVar').style.display='block';
}
</script>
</HEAD>

<BODY>
<a href="javascript:showTable()" ><br>ShowTable</a>


<table border="0" id="dudeTable" style="display:none">
<tr>
dude
</tr>
</table>
</BODY>

Of course the error is: message: Statement on line 6: Type mismatch (usually non-object value supplied where object required)

Thanks for any suggestions.
Reply With Quote
 
>document.getElementsById('globalVar').style.display='block';
[1] If you put quote/apos around a variable name, it is no longer seen as variable.
[2] The method is call getElementById(), no s.
[tt] document.getElementById(globalVar).style.display='block';[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top