ASP雙聯動列表菜單類

來源:互聯網
上載者:User
菜單 <%
'****************************************
'類名:雙聯動菜單類
'****************************************
'本類由 [71port]sean, [71port]80連接埠 原創編寫
'[阿里西西] 修改完善BUG,著作權沒有,任意抄寫,注意完整
'公開發佈於2005年12月10日
'歡迎訪問http://www.71port.com,阿里西西WEB開發


Class DCombo
'****************樣本*********************
'Response.write "<form name=frm>"

'Dim DC
'Set DC =New DCombo
'DC.GroupData="GD,廣東省|GZ,廣州市$GD,廣東省|DG,東莞市$GX,廣西|NN,南寧市$GD,廣東省|SS,深圳$"  
'變數資料格式="第一列表值,名稱|第二列表值,名稱$第一列表值,名稱|第二列表值,名稱$"
'DC.DCform="frm"  'form的名稱要唯一
'DC.DC1Name="第一列表"  '第一列表的名稱
'DC.DC2Name="第一列表"  '第二列表的名稱
'DC.Combo1Name="ComboName1" '第一列表的NAME
'DC.Combo2Name="ComboName2" '第二列表的NAME
'response.Write DC.ReturnDo
'Set DC=nothing

'Response.write "</form>"
'****************樣本*********************

Private myGroupData,myDCform,myCombo1Name,myCombo2Name,myFirstType,mySecType
Private mylvzf,str,f1,f2,cs
Private myDC1Name,myDC2Name,myList1value,myList2value
Private HaveErr,Do_Tmp
Private Sub Class_Initialize()
HaveErr=False
myGroupData=""
myDCform=""
myDC1Name=""
myDC2Name=""
myList1value=""
myList2value=""
myCombo1Name=""
myCombo2Name=""
Do_Tmp=""
End Sub
Public Sub Clear()
HaveErr=False
End Sub
Private Sub Class_Terminate()
Clear()
myGroupData=""
myDCform=""
myDC1Name=""
myDC2Name=""
myList1value=""
myList2value=""
myCombo1Name=""
myCombo2Name=""
Do_Tmp=""
End Sub
Public Property Let GroupData(value)
myGroupData=value
myGroupData=lvzf(myGroupData)
End Property
Public Property Let DCform(value)
myDCform=value
myDCform=lvzf(myDCform)
End Property
Public Property Let Combo1Name(value)
myCombo1Name=value
End Property
Public Property Let Combo2Name(value)
myCombo2Name=value
End Property
Public Property Let DC1Name(value)
myDC1Name=value
End Property
Public Property Let DC2Name(value)
myDC2Name=value
End Property
Public Property Let List1value(value)
myList1value=value
End Property
Public Property Let List2value(value)
myList2value=value
End Property
Public Function lvzf(mylvzf)
mylvzf=replace(mylvzf," ","")
mylvzf=replace(mylvzf,"(","")
mylvzf=replace(mylvzf,")","")
mylvzf=replace(mylvzf,"'","")
mylvzf=replace(mylvzf,"“","")
mylvzf=replace(mylvzf,"”","")
lvzf=mylvzf
End  Function
Public Function GetArray(str,f1,f2)
Dim i,x,y,tmp_a,tmp_b,a,b
tmp_a=split(str,f1)
x=ubound(tmp_a)-1
For i=0 To x
tmp_b=split(tmp_a(i),f2)
If ubound(tmp_b)>=y Then y=ubound(tmp_b)
Next
ReDim Result(x,y)
For a=0 To x
ReDim tmp_b(y)
tmp_b=split(tmp_a(a),f2)
If ubound(tmp_b)<>y Then HaveErr=True : Exit Function
For b=0 To y
Result(a,b)=tmp_b(b)
Next
Next
GetArray=Result
End Function
Public Function  GetGroup(ArrayTmp)
Dim i,ii,iii,j,k,NoCF,FirstType_Temp
ReDim PubTmp(Ubound(ArrayTmp,1))
For i=0 To Ubound(ArrayTmp,1)
NoCF=True
If i=0 Then PubTmp(i)=ArrayTmp(0,0):FirstType_Temp=ArrayTmp(0,0)
For j=0 To i
If PubTmp(j)=ArrayTmp(i,0) Then NoCF=False
Next
If NoCF=True Then FirstType_Temp=FirstType_Temp&"|"&ArrayTmp(i,0) : PubTmp(i)=ArrayTmp(i,0)
Next
myFirstType=Split(FirstType_Temp,"|")
ReDim Result(Ubound(myFirstType),Ubound(ArrayTmp,1)+1)
For ii=0 To Ubound(myFirstType)
Result(ii,0)=myFirstType(ii)
k=0
j=0
NoCF=True
       For iii=0 to Ubound(ArrayTmp,1)
   If ArrayTmp(iii,0)=myFirstType(ii) Then
For j=0 to k
If Result(ii,j)=ArrayTmp(iii,1) Then NoCF=False
Next
If NoCF=True Then k=k+1 : Result(ii,k)=ArrayTmp(iii,1)
End If
Next
Next
GetGroup=Result
End Function
Public Function  ReturnDo()
Dim i,k,m,n
Dim Array_Temp
Array_Temp=GetArray(myGroupData,"$","|")
If HaveErr=True Then  ReturnDo="GroupData資料格式有誤(注意大分割符$小分割符|)" : Exit Function
mySecType=GetGroup(Array_Temp)
Do_Tmp=Do_Tmp&myDC1Name&"<select name="""&myCombo1Name&""" size=""1"" onChange="""&myDCform&"redirect(this.options.selectedIndex)"">"&vbcrlf
For i=0 To Ubound(myFirstType)
 Do_Tmp=Do_Tmp&"<option value="""&split(myFirstType(i),",")(0)&""">"&split(myFirstType(i),",")(1)&"</option>"&vbcrlf
Next
Do_Tmp=Do_Tmp&"</select>"&vbcrlf
Do_Tmp=Do_Tmp&myDC2Name&"<select name="""&myCombo2Name&""" size=""1"">"&vbcrlf
For i=1 To Ubound(mySecType,2)
 If mySecType(0,i)<>"" Then Do_Tmp=Do_Tmp&"<option value="""&split(mySecType(0,i),",")(0)&""">"&split(mySecType(0,i),",")(1)&"</option>"&vbcrlf
Next
Do_Tmp=Do_Tmp&"</select>"&vbcrlf
Do_Tmp=Do_Tmp&"<script>"&vbcrlf
Do_Tmp=Do_Tmp&"var "&myDCform&"groups=document."&myDCform&"."&myCombo1Name&".options.length"&vbcrlf
Do_Tmp=Do_Tmp&" var "&myDCform&"group=new Array("&myDCform&"groups)"&vbcrlf
Do_Tmp=Do_Tmp&"for (i=0; i<"&myDCform&"groups; i++)"&vbcrlf
Do_Tmp=Do_Tmp&""&myDCform&"group[i]=new Array()"&vbcrlf
For m=0 To Ubound(myFirstType)
n=1
k=-1
Do While n<UBound(mySecType,2)
If mySecType(m,n)<>"" Then k=k+1 : Do_Tmp=Do_Tmp& ""&myDCform&"group["&m&"]["&k&"]=new Option("""&split(mySecType(m,n),",")(1)&""","""&split(mySecType(m,n),",")(0)&""")"&vbcrlf
n=n+1
Loop
Next
Do_Tmp=Do_Tmp&"var "&myDCform&"temp=document."&myDCform&"."&myCombo2Name&""&vbcrlf
Do_Tmp=Do_Tmp&"function "&myDCform&"redirect("&myDCform&"x){"&vbcrlf
Do_Tmp=Do_Tmp&"for ("&myDCform&"m="&myDCform&"temp.options.length-1;"&myDCform&"m>0;"&myDCform&"m--)"&vbcrlf
Do_Tmp=Do_Tmp&""&myDCform&"temp.options["&myDCform&"m]=null"&vbcrlf
Do_Tmp=Do_Tmp&"for (i=0;i<"&myDCform&"group["&myDCform&"x].length;i++){"&vbcrlf
Do_Tmp=Do_Tmp&""&myDCform&"temp.options[i]=new Option("&myDCform&"group["&myDCform&"x][i].text,"&myDCform&"group["&myDCform&"x][i].value)"&vbcrlf
Do_Tmp=Do_Tmp&" }"&vbcrlf
Do_Tmp=Do_Tmp&""&myDCform&"temp.options[0].selected=true"&vbcrlf
Do_Tmp=Do_Tmp&" }"&vbcrlf
Do_Tmp=Do_Tmp&" </script>"&vbcrlf
If HaveErr=True Then
ReturnDo="GroupData資料格式有誤(注意大分割符$小分割符|)"
Else
ReturnDo=Do_Tmp
End If
End Function
End Class
%>


相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。