<% userid=Session("userid") sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE (parent_id = (SELECT id FROM enter_individual WHERE menu_name = '在线管理' AND user_id = '"&userid&"')) AND (user_id = '"&userid&"')" rs.Open sql,conn,1,1 Response.Write "<table width=100% border=0 cellspacing=1 cellpadding=0 align=center><tr bgcolor=#3399CC valign=bottom align=center>" sumnum=rs.RecordCount myArray=rs.GetRows() rs.Close () widd=780/sumnum dim i i=0 defaultbgcolor="#3399cc" defaultcolor="#ffffff" defaultlink="#" posit_x=0 'x位置 posit_y=104 'y位置
while i<sumnum
myArray(0,i)=Trim(myArray(0,i)) myArray(1,i)=Trim(myArray(1,i)) myArray(2,i)=Trim(myArray(2,i)) myArray(3,i)=Trim(myArray(3,i)) If myArray(2,i)="" Then myArray(2,i)=defaultbgcolor End If
If myArray(3,i)="" Then myArray(3,i)=defaultcolor End If
If myArray(1,i)="" Then myArray(1,i)=defaultlink End If
Response.Write i&"www" SetMenu myArray(4,i),posit_x,posit_y posit_x=posit_x+widd 'sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual Where parent_id='"&myArray(4,i)&"' and user_id='"&userid&"' " 'Response.Write sql 'rs.Open sql,conn,1,3 'sumnum1=rs.RecordCount 'myArray=rs.GetRows() 'rs.Close ()
'j=0 'While j<sumnum1 ' myArray1(0,j)=Trim(myArray1(0,j)) ' myArray1(1,j)=Trim(myArray1(1,j)) ' myArray1(2,j)=Trim(myArray1(2,j)) ' myArray1(3,j)=Trim(myArray1(3,j)) ' If myArray1(3,j)="" Then ' myArray1(3,j)="#ffffff" ' End If
' If myArray1(1,j)="" Then ' myArray1(1,j)="#" ' End If if i=8 Then Response.Write "yyyyyyyyyyyy" End If i=i+1 Response.Write i&"qqq" Wend
Function SetMenu(parent_id,posit_x,posit_y) dim myArray dim i sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE parent_id = "&parent_id&" AND user_id = '"&userid&"'" 'Response.Write sql 'Response.End rs.Open sql,conn,1,1 If rs.EOF=true Then rs.Close () 'Response.Write parent_id Response.Write "<div id='a"&parent_id&"'></div>" Else
Function SetSubMenu (myArray,sumnum,parent_id,posit_x,posit_y) dim i parent_id="a"&parent_id hh=sumnum*20 Response.Write "<DIV onmouseover=javascript:"&parent_id&".style.display='block' onmouseout=javascript:"&parent_id&".style.display='none' ID='"&parent_id&"' STYLE='position: absolute; top:"&posit_y&"; left:"&posit_x&"; height:"&hh*1&"; width: "&widd&"; display:none;vertical-align: top'><table width=100% border=0 cellspacing=1 cellpadding=0 >" i=0 While i<sumnum*1 myArray(0,i)=Trim(myArray(0,i)) myArray(1,i)=Trim(myArray(1,i)) myArray(2,i)=Trim(myArray(2,i)) myArray(3,i)=Trim(myArray(3,i)) If myArray(2,i)="" Then myArray(2,i)=defaultbgcolor End If
If myArray(3,i)="" Then myArray(3,i)=defaultcolor End If
If myArray(1,i)="" Then myArray(1,i)=defaultlink End If
<script language=vbscript> i=10 function ok() i=0 i=i+1 End function ok() msgbox(i) </script> 运行这个看看!
genuis(不死鸟):你的和下面这个是有区别的,在函数中,i如果没有重定义,就是调用先前定义的全局变量,值当然会变 <script language=vbscript> i=10 //定义全局变量i function ok() dim i=0//定义局部变量i i=i+1 End function ok() msgbox(i) </script>
userid=Session("userid")
sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE (parent_id = (SELECT id FROM enter_individual WHERE menu_name = '在线管理' AND user_id = '"&userid&"')) AND (user_id = '"&userid&"')"
rs.Open sql,conn,1,1
Response.Write "<table width=100% border=0 cellspacing=1 cellpadding=0 align=center><tr bgcolor=#3399CC valign=bottom align=center>"
sumnum=rs.RecordCount
myArray=rs.GetRows()
rs.Close ()
widd=780/sumnum
dim i
i=0
defaultbgcolor="#3399cc"
defaultcolor="#ffffff"
defaultlink="#"
posit_x=0 'x位置
posit_y=104 'y位置
while i<sumnum
myArray(0,i)=Trim(myArray(0,i))
myArray(1,i)=Trim(myArray(1,i))
myArray(2,i)=Trim(myArray(2,i))
myArray(3,i)=Trim(myArray(3,i))
If myArray(2,i)="" Then
myArray(2,i)=defaultbgcolor
End If
If myArray(3,i)="" Then
myArray(3,i)=defaultcolor
End If
If myArray(1,i)="" Then
myArray(1,i)=defaultlink
End If
Response.Write "<td height=20 bgcolor="&myArray(2,i)&" width="&widd&"><a href="&myArray(1,i)&" onmouseover=javascript:a"&myArray(4,i)&".style.display='block' ><font color="&myArray(3,i)&">"&myArray(0,i)&"</a></td>"
i=i+1
Wend
Response.Write "</tr></table>"
i=0
while i<sumnum
Response.Write i&"www"
SetMenu myArray(4,i),posit_x,posit_y
posit_x=posit_x+widd
'sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual Where parent_id='"&myArray(4,i)&"' and user_id='"&userid&"' "
'Response.Write sql
'rs.Open sql,conn,1,3
'sumnum1=rs.RecordCount
'myArray=rs.GetRows()
'rs.Close ()
'j=0
'While j<sumnum1
' myArray1(0,j)=Trim(myArray1(0,j))
' myArray1(1,j)=Trim(myArray1(1,j))
' myArray1(2,j)=Trim(myArray1(2,j))
' myArray1(3,j)=Trim(myArray1(3,j))
' If myArray1(3,j)="" Then
' myArray1(3,j)="#ffffff"
' End If
' If myArray1(1,j)="" Then
' myArray1(1,j)="#"
' End If
if i=8 Then
Response.Write "yyyyyyyyyyyy"
End If
i=i+1
Response.Write i&"qqq"
Wend
'使用递规算法的到下级菜单的函数
'parent_id 父 id; posit_x 弹出层的左边位置; posit_y 弹出层的离上面位置;
Function SetMenu(parent_id,posit_x,posit_y)
dim myArray
dim i
sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE parent_id = "&parent_id&" AND user_id = '"&userid&"'"
'Response.Write sql
'Response.End
rs.Open sql,conn,1,1
If rs.EOF=true Then
rs.Close ()
'Response.Write parent_id
Response.Write "<div id='a"&parent_id&"'></div>"
Else
sumnum=rs.RecordCount
myArray=rs.GetRows()
rs.Close ()
SetSubMenu myArray,sumnum,parent_id,posit_x,posit_y
i=0
while i<sumnum
posit_y=posit_y*1+20
SetMenu myArray(4,i),posit_x,posit_y
i=i+1
Wend
End If
End Function
'设置子菜单函数
'myArray 菜单数据 ,sumnum 数组大小 ,parent_id 层id ;
'posit_x 弹出层的左边位置; posit_y 弹出层的离上面位置;
Function SetSubMenu (myArray,sumnum,parent_id,posit_x,posit_y)
dim i
parent_id="a"&parent_id
hh=sumnum*20
Response.Write "<DIV onmouseover=javascript:"&parent_id&".style.display='block' onmouseout=javascript:"&parent_id&".style.display='none' ID='"&parent_id&"' STYLE='position: absolute; top:"&posit_y&"; left:"&posit_x&"; height:"&hh*1&"; width: "&widd&"; display:none;vertical-align: top'><table width=100% border=0 cellspacing=1 cellpadding=0 >"
i=0
While i<sumnum*1
myArray(0,i)=Trim(myArray(0,i))
myArray(1,i)=Trim(myArray(1,i))
myArray(2,i)=Trim(myArray(2,i))
myArray(3,i)=Trim(myArray(3,i))
If myArray(2,i)="" Then
myArray(2,i)=defaultbgcolor
End If
If myArray(3,i)="" Then
myArray(3,i)=defaultcolor
End If
If myArray(1,i)="" Then
myArray(1,i)=defaultlink
End If
Response.Write "<tr align=center ><td width=100% height=20 bgcolor="&myArray(2,i)&"><a href='"&myArray(1,i)&"' onmouseover=javascript:"&parent_id&".style.display='block';a"&myArray(4,i)&".style.display='block' onmouseout=javascript:a"&myArray(4,i)&".style.display='none'><font color="&myArray(3,i)&">a"&myArray(0,i)&"</font></a></td></tr>" i=i+1
Wend
Response.Write " </table> </DIV>"
End Function
%>
i=10
function ok()
i=0
i=i+1
End function
ok()
msgbox(i)
</script>
运行这个看看!
<script language=vbscript>
i=10 //定义全局变量i
function ok()
dim i=0//定义局部变量i
i=i+1
End function
ok()
msgbox(i)
</script>