Level three Drop-down menu JS Implementation code _ navigation menu

Source: Internet
Author: User
Implementation of the level three Drop-down menu:
Copy Code code as follows:

Function List (IDSTR) {
var name1= "subtree" +IDSTR;
var name2= "img" +IDSTR;
var objectobj=document.all (name1);
var imgobj=document.all (name2);
alert (imgobj);
if (objectobj.style.display== "None") {
for (i=1;i<22;i++) {
var name3= "img" +I;
var name= "subtree" +i;
var o=document.all (name);
if (o!=undefined) {
O.style.display= "None";
var image=document.all (Name3);
alert (image);
Image.src= "<%=basepath%>admin/images/ico04.gif";
if (idstr>12&&idstr<20) {
document.getElementById ("Subtree11"). style.display= "";
document.getElementById ("Img11"). src= "<%=basepath%>admin/images/ico03.gif";
}
}
}
Objectobj.style.display= "";
Imgobj.src= "<%=basepath%>admin/images/ico03.gif";
}
else{
Objectobj.style.display= "None";
Imgobj.src= "<%=basepath%>admin/images/ico04.gif";
}
}

Code explanation: such as
, Idstr is a numeric character used to differentiate between different submenus and pictures. Through document.all (name1) to get all the ID name1 (a variable) submenu, here
In fact, there is only one, to judge if the current is hidden state, then enter the loop, and if the element is defined (for convenience, some of the submenus fetched through I may be undefined) hide all submenus (except Level 1 menu, including 2, Level 3 menu), change the current sibling menu icon, and finally display the currently selected menu , and replace the currently selected icon. There is a special situation: when idstr>12&&idstr<20, then it is the second level menu to activate the third Level menu expansion, the following figure: selected paper management, because results-based management is the parent of the paper Management menu, results Management can not hide, so there is if ( IDSTR&GT;12&AMP;&AMP;IDSTR&LT;20) followed by the code block. The last else is well understood, if the currently selected menu is expanded and hidden, and the icon is replaced.
Copy Code code as follows:

function Tupian (IDT) {
var nametu= "Xiaotu" +IDT;
var tp = document.getElementById (Nametu);
Tp.src= "<%=basepath%>admin/images/ico05.gif";//Picture ico05 a white square
for (Var i=1;i<32;i++)
{
var nametu2= "Xiaotu" +i;
if (i!=idt*1)
{
var Tp2=document.getelementbyid (' Xiaotu ' +i);
if (tp2!=undefined)
{tp2.src= "<%=basepath%>admin/images/ico06.gif";} Picture ico06 as a blue square
}
}
}

Code Description: Just replace the icon, indicating activation or deactivation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.