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

Object Required Error

Status
Not open for further replies.

sr1979

MIS
Joined
Jan 13, 2003
Messages
3
Location
US
I am getting an error that says an object is required. This code is for a hier menu. I dont know why the first layer works but the second doesnt since i used the same code. the error is
"Object Required: 'document.all.item(...)'
any insight would be great!
Code:
DIM menuID,menuObj,bkgrnd
DIM menuID2,menuObj2,bkgrnd2
SUB ShowHide(menuID)
menuObj = "Link" & menuID
bkgrnd = "Head" & menuID
// CHECK IF OPEN
if document.all.item(menuObj).className = "LINKSON" then    'IF MENU OPEN THEN CLOSE
document.all.item(menuObj).className = "LINKSOFF"
document.all.item(bkgrnd).style.backgroundColor = "Red"   ' SET CELL BACKGROUND COLOR Red           
ELSE
document.all.item(menuObj).className = "LINKSON"               ' OPEN MENU   
document.all.item(Bkgrnd).style.backgroundColor = "Black"  ' SET CELL BACKGROUND COLOR Black           
END IF
END SUB

SUB ShowHide2(menuID2)
menuObj2 = "Link" & menuID2
bkgrnd2 = "Head" & menuID2
// CHECK IF OPEN
if document.all.item(menuObj2).className = "LINKSON" then    'IF MENU OPEN THEN CLOSE
document.all.item(menuObj2).className = "LINKSOFF"
document.all.item(bkgrnd2).style.backgroundColor = "Red"   ' SET CELL BACKGROUND COLOR Red           
ELSE
document.all.item(menuObj2).className = "LINKSON"               ' OPEN MENU   
document.all.item(Bkgrnd2).style.backgroundColor = "Black"  ' SET CELL BACKGROUND COLOR Black           
END IF
END SUB

</SCRIPT>
</HEAD>
<BODY>
<TABLE cellspacing=&quot;1&quot;>
  <TBODY>
  <TR>
    <TD class=HEADING id=head0 ONCLICK=ShowHide(0) align=middle>Standards/Policies</TD></TR>
  <TR>
    <TD align=left bgColor=#FFFFFF><!-- Menu 1 -->
     
      <DIV class=LINKSOFF id=Link0>
      <table cellpadding=0 cellspacing=0 border= width=&quot;87&quot;>
		<tr>
		<td class=HEADING2 ONCLICK=ShowHide2(12) width=&quot;83&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot;>option 1</font>
		<DIV class=LINKSOFF id=Link12>
			<br><font color=&quot;#FFFFFF&quot;>
            <a href=&quot;Standards%20and%20Policies/Option%201/Test%201.doc&quot;>test 1</a></font><br>
				<font color=&quot;#FFFFFF&quot;>test 2</font><br>
				<font color=&quot;#FFFFFF&quot;>test 3</font></DIV>
		</td></tr>
		
		<tr>
		<td class=HEADING2 ONCLICK=ShowHide2(13) width=&quot;83&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot;>option 2</font>
		<DIV class=LINKSOFF id=Link13>
				<br><font color=&quot;#FFFFFF&quot;>test 1</font><br>
				<font color=&quot;#FFFFFF&quot;>test 2</font><br>
				<font color=&quot;#FFFFFF&quot;>test 3</font></DIV>
		</td></tr>
		
		<tr>
		<td class=HEADING2 ONCLICK=ShowHide2(14) width=&quot;83&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot;>option 3</font>
		<DIV class=LINKSOFF id=Link14>
				<br><font color=&quot;#FFFFFF&quot;>test 1</font><br>
				<font color=&quot;#FFFFFF&quot;>test 2</font><br>
				<font color=&quot;#FFFFFF&quot;>test 3</font></DIV>
		</td></tr>
	  </table>
      
    </TD>
  </TR>
 
Try using set:

set menuObj = &quot;Link&quot; & menuID
set bkgrnd = &quot;Head&quot; & menuID


and

set menuObj2 = &quot;Link&quot; & menuID2
set bkgrnd2 = &quot;Head&quot; & menuID2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top