日期:2008-12-09  浏览次数:21023 次

<script>
var m_oXMLDoc = new ActiveXObject("Microsoft.XMLDOM");
//--------------cid为父级ID
var m_sBaseSrc = "Tree.ASP?cid=";
//---------------id 为所属类型-----
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("==请选择==");
for (var i=0; i < aryXMLNodes.length; i++)
{
node = aryXMLNodes[i];
objSelect.options[i+1] = new Option(node.getAttribute("Title"),node.getAttribute("cId"));

//-------------------请注意这里,初始选择
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(o