One drag three pull-down menu (js+xml+asp)

Source: Internet
Author: User
js|xml| Menu | dropdown <script>
var m_oxmldoc = new ActiveXObject ("Microsoft.XMLDOM");
--------------CID is the parent ID
var m_sbasesrc = "tree.asp?cid=";
---------------ID is the owning type-----
var m_sbasesrc1 = "&id=";
var m_post=3;

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


if (objselectname== "Jz_3") {strxmlsrc=strxmlsrc+m_sbasesrc1+0;}
if (objselectname== "jz_25") {strxmlsrc=strxmlsrc+m_sbasesrc1+1;m_post=2;}
if (objselectname== "Jz_9") {strxmlsrc=strxmlsrc+m_sbasesrc1+2;}
if (objselectname== "Jz_10") {strxmlsrc=strxmlsrc+m_sbasesrc1+3;}

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 ("Tree_0");
Objselect.options[0] = new Option ("= = Please select = =");
for (Var i=0 i < aryxmlnodes.length; i++)
{
node = aryxmlnodes[i];
OBJSELECT.OPTIONS[I+1] = new Option (Node.getattribute ("Title"), Node.getattribute ("cId"));

-------------------Please note here that the initial selection
if (Node.getattribute ("CId") ==1| | Node.getattribute ("CId") ==2| | Node.getattribute ("CId") ==3| | Node.getattribute ("CId") ==4)
{
Objselect.options[i+1].selected=true
}

}

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

if (objselect.childselectname!= null&&m_post>0)
{
m_post=m_post-1;
Objselect.onchange = Function ("var val = document.all.jz_3.value; Bindselect (M_sbasesrc+val, ' +objselect.childselectname+ "', '" +defaultval+ "); if (val!= ') Document.all.materialclasscode.value=m_post; ");
Objselect.fireevent ("onchange");
}
Else
{
Objselect.onchange = Function ("var val = document.all.jz_3.value;if (val!=") document.all.materialclasscode.value=m_ Post; ");
}
}
}

function Initselect (defaultval)
{
Document.all.MaterialClassCode.value = "";
Bindselect (m_sbasesrc + "0", "jz_3", defaultval);
document.write (m_sbasesrc + "0" + "&cid=" +0, "Jz_3", defaultval);

Bindselect (m_sbasesrc + "1", "Jz_9", 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>

------------------------------------tree.asp---------

<!--#include file= ". /inc/asp/all.asp "-->
<%
Tree=3
Dim xmldoc, TMP (3), root,rows_a (1), I,newelem
' Dim root as IXMLDOMElement
' Dim Newelem as IXMLDOMElement
Response. ContentType = "text/xml" ' Output format is XML

TMP (0) = Request ("CID")
TMP (1) = Request ("id")
If tmp (0) =empty or TMP (1) =empty Then
Response.Write "<Tree/>"
Response.End
End If

Set Xmldoc=server. CreateObject ("Microsoft.XMLDOM") ' New Xmldom object

Xmldoc.loadxml ("<tree cid=" "" &tmp (0) & "" src= "" tree.asp?cid= "&tmp (0) &" "/>")
S



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.