ASP multi-level linkage dish single

Source: Internet
Author: User

ASP multilevel Linkage menu, Multilevel linkage menu

<!--#include file= "adoconn.asp"-->
<script>
var m_oxmldoc = new ActiveXObject ("Microsoft.XMLDOM");
var m_sbasesrc = "Tree.asp?" Parentcode= ";

function Bindselect (STRXMLSRC, Objselectname, Defaultval)
{
M_oxmldoc.async = true;
M_oxmldoc.onreadystatechange = Function ("fnloadcomplete (' + objselectname +" ', ' "+ Defaultval + ');");
M_oxmldoc.load (STRXMLSRC);
}

function Fnloadcomplete (objselectname, Defaultval)
{
var objselect = Document.all[objselectname];
var aryxmlnodes;
var node;
if (Objselect = null)
Return
Try
{
var ireadystate = m_oxmldoc.readystate;
}
catch (E)
{
Return
}

if (ireadystate!= 4) return;

if (M_oxmldoc!= null && m_oxmldoc.xml!= "")
{
objselect.length = 0;
Aryxmlnodes = M_oXMLDoc.documentElement.selectNodes ("TreeNode");
Objselect.options[0] = new Option ("= all = =");
for (Var i=0 i < aryxmlnodes.length; i++)
{
node = aryxmlnodes[i];
OBJSELECT.OPTIONS[I+1] = new Option (Node.getattribute ("Title"), Node.getattribute ("Materialclasscode"));
}

if (defaultval!= null && defaultval!= "" && objselect.length > 1)
{
Setselectedvalue (Objselect, Defaultval)
}

if (objselect.childselectname!= null)
{
Objselect.onchange = Function ("var val = this.options[this.selectedindex].value; Bindselect (M_sbasesrc+val, ' +objselect.childselectname+ "', '" +defaultval+ "); if (val!= ') Document.all.materialclasscode.value=val; ");
Objselect.fireevent ("onchange");
}
Else
{
Objselect.onchange = Function ("var val = this.options[this.selectedindex].value;if (val!= ')" Document.all.materialclasscode.value=val; ");
}
}
}

function Initselect (defaultval)
{
Document.all.MaterialClassCode.value = "";
Bindselect (M_sbasesrc + ", MaterialClass1", defaultval);
}

function Equality (VAL1,VAL2)
{
if (Val1.length < Val2.length | | | val2 = "")
return false;
Return (VAL1.SUBSTR (0,val2.length) = = Val2)
}

function Setselectedvalue (osel,val)
{
if (val = null)
Return
for (var i=0; i<osel.length; i++)
{
if (Equality (Val, Osel.options[i].value))
{
Osel.selectedindex = i;

if (osel.childselectname = null)
Osel.fireevent ("onchange");
Break
}
}
}

Window.onload = function () {initselect ();}
</script>
<nobr>
<select name= "MaterialClass1" childselectname= "MaterialClass2" ></select>
<select name= "MaterialClass2" childselectname= "MATERIALCLASS3" ></select>
<select name= "MATERIALCLASS3" childselectname= "MATERIALCLASS4" ></select>
<select name= "MATERIALCLASS4" ></select>
</nobr>
<input type= "hidden" name= "Materialclasscode" >

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.