注:由于本人主要做后台的就只用到了IO空间下面的一些东西,贴个小小的级联效果来吧,
废话少说先拿代码说话了,
复制代码 代码如下:
Demo.show={
Test:function(e,Y)
{
config=Demo.config;
function onshengchange(e)
{
var sheng = Y.Node.get('#'+config.sheng).get("value");
var speccode = Y.Node.get('#'+config.speciality);
var years = Y.Node.get('#'+config.years);
var timeslist =Y.Node.get('#'+config.times);
var content="<option selected=selected>请选择</option>";
speccode.setContent("<option selected=selected>加载数据....</option>");
years.setContent(content);
timeslist.setContent(content);
var requestSpeciality = Y.io("Test.aspx", {
method:"POST",
data:"type=sheng&sheng="+sheng,
arguments:{event:"cclchange"},
on:
{
success:successHandler,
failure:failureHandler
}
}
);
}
function onspecialitychange(e)
{
var sheng = Y.Node.get('#'+config.sheng).get("value");
var speccode = Y.Node.get('#'+config.speciality).get("value");
var years = Y.Node.get('#'+config.years);
var timeslist =Y.Node.get('#'+config.times);
var content="<option selected=selected>请选择</option>";
years.setContent("<option selected=selected>加载数据....</option>");
timeslist.setContent(content);
var requestSpeciality = Y.io("Test.aspx", {
method:"POST",
data:"type=speciality&cclid="+ccl+"&speccode="+speccode,
arguments:{event:"specchange"},
on:
{
success:successHandler,
failure:failureHandler
}
}
);
}
function onyearchange(e)
{
var sheng = Y.Node.get('#'+config.sheng).get("value");
var speccode = Y.Node.get('#'+config.speciality).get("value");
var year = Y.Node.get('#'+config.years).get("value");
var timeslist =Y.Node.get('#'+config.times);
timeslist.setContent("<option selected=selected>加载数据....</option>");
var requestSpeciality = Y.io("Test.aspx", {
method:"POST",
data:"type=year&sheng="+sheng+"&speccode="+speccode+"&year="+year,
arguments:{event:"yearchange"},
on:
{
success:successHandler,
failure:failureHandler
}
}
);
}
function ontimeslistchagne(e){
//这里可以一直连下去
}
function successHandler(id, o,args){
if(args!=null)
if(args.event!=null)
{
if(args.event=='shengchange')
{
var root = o.responseXML.documentElement;
var speciality =Y.Node.get('#'+config.speciality);
var content="<option selected=selected>请选择</option>";
for(i=0;i<root.childNodes.length;i++)
{
var node=root.childNodes[i];
var value=node.getElementsByTagName("Code")[0].text;
var text=node.getElementsByTagName("CName")[0].text;
content+="<option value="+value +">"+text+"</option>";
}
speciality.setContent(content);
}
else if(args.event=='specchange')
{
var root = o.responseXML.documentElement;
var yearlist =Y.Node.get('#'+config.years);
var content="<option selected=selected>请选择</option>";
for(i=0;i<root.childNodes.length;i++)
{
var value=root.childNodes[i].text;
var text=value;
content+="<option value="+value +">"+text+"</option>";
}
yearlist.setContent(content);
}
else if(args.event=='yearchange')
{
var root = o.responseXML.documentElement;
var timeslist =Y.Node.get('#'+config.times);
var content="<option selected=selected>请选择</option>";
var times=Y.DataType.Number.parse(root.text);
if(times==null)
times=0;
for(i=0;i<times;i++)
{
content+="<option value="+(i+1) +">"+(i+1)+"</option>";
}
timeslist.setContent(content);
}
}
}
function failureHandler(id, o){
alert("数据获取成功");
}
var sheng = Y.Node.get('#'+config.sheng);
var speccode = Y.get('#'+config.speciality);
var year = Y.get('#'+config.years);
var timeslist =Y.Node.get('#'+config.times);
sheng.on("change",oncclchange);
speccode.on("change",onspecialitychange);
year.on("change",onyearchange);
timeslist.on("change",ontimeslistchagne);
}
};
YUI().use("node","datatype-number","io-base",function(Y) {
function onload(e)
{
Demo.show.Test(e,Y);
}
Y.on("load", onload, window);
});
复制代码 代码如下: