I have several sections of text that I want to keep hidden unless a particular button is clicked. When a particular button is clicked, it should hide all sections of text except the section for it's button (button 0 should display Text0 and hide all other sections, button 1 should display Text1 and hide all other sections...).
When I click the button I get an error "Object expected". Can anyone tell me what I am doing wrong?
Here is my HTML:
<input type="button" name="button0" value=http://www.webdeveloper.com/forum/archive/index.php/"Button0" onClick="MM_callJS('showText("Text", 0)')">
<input type="button" name="button1" value=http://www.webdeveloper.com/forum/archive/index.php/"button1" onClick="MM_callJS('showText("Text", 1)')">
<input type="button" name="button2" value=http://www.webdeveloper.com/forum/archive/index.php/"button2" onClick="MM_callJS('showText("Text", 2)')">
<div ID="Text0" style="display:none;">Some text</div>
<div ID="Text1" style="display:none;">Other text</div>
<div ID="Text2" style="display:none;">More text</div>
And here are the javascript functions:
function MM_callJS(jsStr)
{
return eval(jsStr)
}
function showText(ObjName, n)
{
for (var i = 0; i < 3; i++)
{
var TabName = window.document.getElementByID(ObjName+i);
if (i == n)
{
TabName.style.display="BLOCK";
}
else
{
TabName.style.display="NONE";
}
}
}
When I click the button I get an error "Object expected". Can anyone tell me what I am doing wrong?
Here is my HTML:
<input type="button" name="button0" value=http://www.webdeveloper.com/forum/archive/index.php/"Button0" onClick="MM_callJS('showText("Text", 0)')">
<input type="button" name="button1" value=http://www.webdeveloper.com/forum/archive/index.php/"button1" onClick="MM_callJS('showText("Text", 1)')">
<input type="button" name="button2" value=http://www.webdeveloper.com/forum/archive/index.php/"button2" onClick="MM_callJS('showText("Text", 2)')">
<div ID="Text0" style="display:none;">Some text</div>
<div ID="Text1" style="display:none;">Other text</div>
<div ID="Text2" style="display:none;">More text</div>
And here are the javascript functions:
function MM_callJS(jsStr)
{
return eval(jsStr)
}
function showText(ObjName, n)
{
for (var i = 0; i < 3; i++)
{
var TabName = window.document.getElementByID(ObjName+i);
if (i == n)
{
TabName.style.display="BLOCK";
}
else
{
TabName.style.display="NONE";
}
}
}