|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
asp可以轻松地实现对页面内容的动态控制,根据不同的浏览者,显示不同的页面内容。而浏览者一点觉察不出来,就像为他专门制作的页面一样。使用各种各样的组件,asp可以完成无比强大的功能。js|xml|菜单|下拉 <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(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"'输入格局为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")'新建xmldom对象
xmlDoc.loadXML("<Tree cId="""&tmp(0)&""" Src=""Tree.asp?cid="&tmp(0)&"""/>")
s</p> ASP由于使用了COM组件所以它会变的十分强大,但是这样的强大由于Windows NT系统最初的设计问题而会引发大量的安全问题。只要在这样的组件或是操作中一不注意,哪么外部攻击就可以取得相当高的权限而导致网站瘫痪或者数据丢失; |
|