Parameters for js display layer and js hidden layer Functions

Source: Internet
Author: User

Parameters for js display layer and js hidden layer Functions

/*
======================================
Function: display or hide Layer
ShowDiv (divId_array, showLocality_array)
Parameter description:
DivId_array all layer IDs to be operated, separated by commas
ShowLocality_array all layers to be displayed are located in the DivIdArray parameter. If it is "0" or empty, all are displayed. If it is set to negative, all are hidden.
For example: showDiv ('div3, div1, div2', '2, 3') shows the second (div1) and third layer (div2), the first layer (div3) will be hidden.
======================================
*/
Function showDiv (divId_array, showLocality_array)
{
Var div_array = new Array ();
Var locality_array = new Array ();
Var intLocality; // showLocality_array array Length
Var intDiv; // div_array Length
Var intTemp = 1; // Temporary Variable
Var intTmp = 1; // Temporary Variable

// Initialization
If (divId_array)
{
Div_array = divId_array.split (",");
} Else {
IntDiv = 0;
}
If (showLocality_array)
{
Locality_array = showLocality_array.split (",");
IntLocality = locality_array.length;

For (var n = 0; n <intLocality; n ++)
{
IntTemp * = locality_array [n];

}
If (intTemp <= 0)
{
IntLocality = intTemp;
} Else {
IntLocality = div_array.length;

While (intLocality> 0)
{
IntLocality-= 1;
Document. getElementById ("" + div_array [intLocality] + ""). style. display = "none ";
}
IntLocality = 1;
}
} Else {
IntLocality = 0;
}

// Display the specified layer
If (intDiv! = 0 & intLocality> 0)
{
IntDiv = div_array.length;
IntLocality = locality_array.length;

// Sort the locality_array bkjia.com
For (var n = 0; n <intLocality; n ++)
{
IntTemp = locality_array [n];

For (var m = n + 1; m <intLocality; m ++)
{
If (locality_array [n]> locality_array [m])
{
Locality_array [n] = locality_array [m];
Locality_array [m] = intTemp;
IntTemp = locality_array [n];
}
}
}

IntLocality = locality_array.length;
IntTemp = 0;

//
While (intTemp <intLocality)
{
If (locality_array [intTemp]-1) <div_array.length)
{
IntTmp = locality_array [intTemp]-1;
Document. getElementById ("" + div_array [intTmp] + ""). style. display = "block ";
}

IntTemp + = 1;
}
}
Else if (intLocality = 0)
{// Display all layers
IntLocality = div_array.length;

While (intLocality> 0)
{
IntLocality-= 1;
Document. getElementById ("" + div_array [intLocality] + ""). style. display = "block ";
}
} Else {// hide all layers
IntLocality = div_array.length;

While (intLocality> 0)
{
IntLocality-= 1;
Document. getElementById ("" + div_array [intLocality] + ""). style. display = "none ";
}
}
}

Related Article

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.