日期:2014-05-18 浏览次数:20477 次
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Infinite_Class.aspx.cs" Inherits="Web.AJAXPro.Infinite_Class" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Infinite_Class无限级分类测试(作者QQ:241181876)--转载请注明出处</title> </head> <body> <form id="form1" runat="server"> <div> <span id="select1"></span></div> <hr /> <div id="test">ttt</div> <input type="button" value="设置值" onclick="iaocLianDong.SetValue(1,4,12,14,15,16,17,18,19);"> <input type="button" value="取值" onclick="alert(iaocLianDong.GetValue());"> <input type="button" value="读取第一个值" onclick="alert(document.getElementById('select1').childNodes[0].value)" /> <script language="javascript" type="text/javascript" defer="defer"> //Infinite_Class无限级分类测试(作者QQ:241181876)--转载请注明出处 function CreateOption(i1,pid1,myWebClientID) { var myWebClientID = document.getElementById(myWebClientID); this.CreateNewOption = function(i,pid) { var arr = Web.AJAXPro.Infinite_Class.GetClassList(""+pid+"").value; while(myWebClientID.childNodes.length-1>=i) { myWebClientID.removeChild(myWebClientID.childNodes[myWebClientID.childNodes.length - 1]); } var tmp; var created = false; for ( var j = 0; j < arr.Rows.length; j++) { if (arr.Rows[j][arr.Columns[2].Name] == pid) { if (created==false) { created = true; tmp = document.createElement("select"); tmp.setAttribute("id", "liandong_" + i); //tmp.setAttribute("multiple", "multiple");// tmp.options[tmp.length] = new Option("请选择", "-1"); tmp.onchange = function() { pp(parseInt(tmp.getAttribute("id").replace("liandong_",""))+1,tmp.value); }; myWebClientID.appendChild(tmp); } tmp.options[tmp.options.length] = new Option(arr.Rows[j][arr.Columns[1].Name], arr.Rows[j][arr.Columns[0].Name]); } } } var pp = this.CreateNewOption; this.GetValue = function() { var value = ""; for (var i=0; i<myWebClientID.childNodes.length; i++) { var obj = myWebClientID.childNodes[i]; for (var j=0; j<obj.options.length; j++) { if (obj.options[j].selected) { value += obj.options[j].value + ","; break; } }