看看这个如何,是否符合阁下要求?
<!DOCTYPE html><html>
<head>
<meta http-equiv="Content-Type" content="text/html charset=gb2312">
<title></title>
<style type="text/css">
.menus{
float:left
color:#0C0
font-size:18px
border:2px #0C0 solid
width:120px
height:40px
text-align:center
padding-top:20px
margin-right:-2px
}
.add{
float:left
color:#999
background-color:#F8F8F8
font-size:32px
border:1px #CCC solid
border-left:2px #0C0 solid
width:120px
height:50px
text-align:center
padding-top:12px
cursor:pointer
}
</style>
<script type="text/javascript">
window.onload=function(){
var add1=document.getElementById("add")
add1.onclick=function(){
addElement()
}
}
var i=1
function addElement(){
var box=document.getElementById("box")
var oDiv=document.createElement("div")
oDiv.setAttribute("class","menus")
oDiv.appendChild(document.createTextNode(prompt("在此输入菜单名称")))
box.appendChild(oDiv)
i++
box.insertBefore(oDiv,box.childNodes[i])
}
</script>
</head>
<body>
<div id="box">
<div class="menus">菜单名称</div>
<div class="add" id="add"><b>+</b></div>
</div>
</body>
</html>
鼠标移出导航二级菜单就消失是因为二级菜单没有在导航容器内,所以mouseout条件满足了,自然就消失了。<!--一级导航-->
<ul class='menu'>
<li class='menu-lei'>
<!--二级菜单-->
<ul class='menu-sub'>
<li class='menu-sub-cnt' name='b'></li>
<li class='menu-sub-cnt' name='b'></li>
...
</ul>
</li>
<li class='menu-lei'>
<!--二级菜单-->
<ul class='menu-sub'>
<li class='menu-sub-cnt' name='b'></li>
<li class='menu-sub-cnt' name='b'></li>
...
</ul>
</li>
...
</ul>
结果改成这样就行了,这样二级菜单在导航容器内,所以不会由于mouseout条件必须满足从二级菜单移出才会执行。
$(".menu_lei").each(function(){
$(this).mouseover(function(){
$(this).find(".menu-sub").show()
})
$(this).mouseout(function(){
$(this).find(".menu-sub").hide()
})
})
三级联动,用asp控制输出js,一次过调出所有项目数据,参考代码<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conn.asp"-->
<!-- #include file="inc/checklogin.asp"-->
<!--#include file="inc/md5.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<title>manageproductitem</title>
<link href="inc/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function check()
{
if( window.myform.ChannelId1.value==""){alert("please select big class")return false}
if( window.myform.ChannelId2.value==""){alert("please select small class")return false}
if( window.myform.ChannelId3.value==""){alert("please select product")return false}
quan=window.myform.num.value
if( window.myform.ino.value==""){alert("please input Item No.")return false}
if( window.myform.itemname.value==""){alert("please input item name")return false}
if( window.myform.num.value==""){alert("please input num")return false}
for (nIndex=0nIndex<quan.lengthnIndex++)
{
cCheck = quan.charAt(nIndex)
if (!IsDigit(cCheck))
{
alert("num must be a number")
return false
}
}
}
function IsDigit(cCheck)
{
return (('0'<=cCheck) &&(cCheck<='9'))
}
var g_selProvince
var g_selCity
var g_selCounty
//一级目录
var Provinces=new Array()
<%
set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from bigclass",conn,3,3
i=0
do while not rs1.eof
%>
Provinces[<%=i%>]=new Array("<%=rs1("bigclassid")%>","<%=trim(rs1("bigclassname"))%>")
<%rs1.movenext
i=i+1
loop%>
//二级目录
var Citys=new Array()
<%
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from smallclass",conn,3,3
i=0
do while not rs2.eof
%>
Citys[<%=i%>]=new Array("<%=rs2("bigclassid")%>","<%=rs2("smallclassid")%>","<%=trim(rs2("smallclassname"))%>")
<%rs2.movenext
i=i+1
loop%>
//Array("本级索引","与下级索引","显示的值")
//三级目录
var Countys=new Array()
<%
set rs3=server.CreateObject("adodb.recordset")
rs3.open "select * from product",conn,3,3
i=0
do while not rs3.eof
%>
Countys[<%=i%>]=new Array("<%=rs3("smallclassid")%>","<%=rs3("productid")%>","<%=trim(rs3("productname"))%>"),
<%rs3.movenext
i=i+1
loop%>
//Array("本级索引","与下级索引","显示的值")
function FillProvinces(selProvince)
{
selProvince.options[0]=new Option("select bigclass","")
for(i=0i<Provinces.lengthi++)
{
selProvince.options[i+1]=new Option(Provinces[i][1],Provinces[i][0])
selProvince.options[0].selected=true
}
selProvince.length=i+1
}
function FillCitys(selCity,ProvinceCode)
{
selCity.options[0]=new Option("select small class","")
count=1
for(i=0i<Citys.lengthi++)
{
if(Citys[i][0].toString()==ProvinceCode)
{
selCity.options[count]=new Option(Citys[i][2],Citys[i][1])
selCity.options[0].selected = true
count=count+1
}
}
selCity.length=count
}
function FillCountys(selCounty,CityCode)
{
selCounty.options[0]=new Option("select product","")
count=1
for(i=0i<Countys.lengthi++)
{
if(Countys[i][0]==CityCode)
{
selCounty.options[count]=new Option(Countys[i][2],Countys[i][1])
selCounty.options[0].selected = true
count=count+1
}
}
selCounty.length=count
}
function City_onchange()
{
FillCountys(g_selCounty,g_selCity.value)
}
function Province_onchange()
{
FillCitys(g_selCity,g_selProvince.value)
City_onchange()
}
function InitCitySelect(selProvince,selCity,selCounty)
{
g_selProvince=selProvince
g_selCity=selCity
g_selCounty=selCounty
selProvince.onchange=Province_onchange
selCity.onchange=City_onchange
FillProvinces(selProvince)
Province_onchange()
}
</script>
</head>
<body><br>
<table width="80%" border="0" align="center" cellpadding="3" cellspacing="0">
<FORM name=myform action="manageproductitem.asp?action=add" method="post" onSubmit="return check()">
<tr>
<td align="right">product:</td>
<td><SELECT id=ChannelId1 name=ChannelId1></SELECT>
<SELECT id=ChannelId2 name=ChannelId2></SELECT>
<SELECT id=ChannelId3 name=ChannelId3></SELECT>
<SCRIPT language=javascript>
InitCitySelect(document.myform.ChannelId1,document.myform.ChannelId2,document.myform.ChannelId3)
</SCRIPT></td>
</tr>
<tr>
<td align="right">item:</td>
<td><input name="itemname" type="text" id="itemname"></td>
</tr>
<tr>
<td align="right">No.:</td>
<td><input name="ino" type="text" id="ino"></td>
</tr>
<tr>
<td align="right">nums:</td>
<td><input name="num" type="text" id="num" size="4"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="submit"></td>
</tr>
</FORM>
</table>
<br>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<tr>
<td>product item </td>
<td>No.</td>
<td>product</td>
<td>small class name</td>
<td>big classname</td>
<td>num</td>
<td>edit</td>
</tr>
<% dim rs,sql
i=0
page=request("page")
if page<1 then page=1
page=int(page)
sql="select item.*,product.*,smallclass.*,bigclass.* from item,product,smallclass,bigclass where item.productid=product.productid and item.smallclassid=smallclass.smallclassid and item.bigclassid=bigclass.bigclassid order by item.itemid desc"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,3,3
pagesize=10
if rs.eof then
response.Write("no recoord")
else
rs.pagesize=pagesize
rs.absolutepage=page
do while not rs.eof and i<pagesize
%>
<form name="editpro" action="manageproductitem.asp?action=edit&id=<%=rs("itemid")%>" method="post">
<tr>
<td><input name="itemname2" type="text" id="itemname2" value="<%=trim(rs("itemname"))%>" size="16"></td>
<td><input name="ino2" type="text" id="ino2" value="<%=trim(rs("ino"))%>" size="12"></td>
<td><%=rs("productname")%></td>
<td><%=rs("smallclassname")%></td>
<td><%=rs("bigclassname")%></td>
<td><input name="num2" type="text" id="num2" value="<%=trim(rs("num"))%>" size="10"></td>
<td><input type="button" value="del" onClick="location.href='manageproductitem.asp?action=del&id=<%=rs("itemid")%>'"><input type="submit" value="edit"></td>
</tr></form>
<%
rs.movenext
i=i+1
loop
end if%>
</table>
<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="right"><a href="manageproductitem.asp?page=<%=page-1%>">Proview</a><a href="manageproductitem.asp?page=<%=page+1%>">Next</a></td>
</tr>
</table>
</body>
</html>
<%
if request("action")="add" then
set rs4=server.CreateObject("adodb.recordset")
rs4.open "select * from item where bigclassid="&cint(trim(request("ChannelId1")))&" and smallclassid="&cint(trim(request("ChannelId2")))&" and productid="&cint(trim(request("ChannelId3")))&"",conn,3,3
do while not rs4.eof
if trim(rs4("itemname"))=trim(request("itemname")) then
response.Write("<script>alert('the user name was exist')location.href='manageproductitem.asp'</script>")
fla=1
end if
rs4.movenext
loop
if fla<>1 then
rs4.addnew
rs4("itemname")=trim(request("itemname"))
rs4("bigclassid")=cint(trim(request("ChannelId1")))
rs4("smallclassid")=cint(trim(request("ChannelId2")))
rs4("productid")=cint(trim(request("ChannelId3")))
rs4("ino")=trim(request("ino"))
rs4("num")=cint(trim(request("num")))
rs4.update
response.Redirect("manageproductitem.asp")
end if
rs4.close
set rs4=nothing
end if
if request("action")="del" then
set rs5=server.CreateObject("adodb.recordset")
rs5.open "delete from item where itemid="&cint(trim(request("id")))&"",conn,3,3
response.Redirect("manageproductitem.asp")
end if
if request("action")="edit" then
set rs6=server.CreateObject("adodb.recordset")
rs6.open "select * from item where itemid="&cint(trim(request("id")))&"",conn,3,3
rs6("itemname")=trim(request("itemname2"))
rs6("num")=cint(trim(request("num2")))
rs6("ino")=trim(request("ino2"))
rs6.update
response.Redirect("manageproductitem.asp")
end if
%>
通过中转页面回传参数可做无限级联动,缺点是项目多时需多次跳转页面,执行速度较慢
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conn.asp"-->
<!-- #include file="inc/checklogin.asp"-->
<!--#include file="inc/md5.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">
<title>edit manage</title>
<link href="inc/style.css" rel="stylesheet" type="text/css">
<script src="inc/setDate.js"></script>
<script language="javascript">
function check()
{
if( window.myform.Customername.value==""){alert("please input Customername")return false}
if( window.myform.Address.value==""){alert("please input Address")return false}
if( window.myform.Tel.value==""){alert("please input Tel")return false}
if( window.myform.Purchasedate.value==""){alert("please input Purchasedate")return false}
if( window.myform.Purchaseloaction.value==""){alert("please input Purchaseloaction")return false}
if( window.myform.invoiceno.value==""){alert("please input invoiceno")return false}
if( window.myform.bigclass.value==""){alert("please input bigclass")return false}
if( window.myform.smallclass.value==""){alert("please input smallclass")return false}
if( window.myform.product.value==""){alert("please input product")return false}
if( window.myform.item.value==""){alert("please input item")return false}
if( window.myform.num.value==""){alert("please input num")return false}
quan=window.myform.num.value
for (nIndex=0nIndex<quan.lengthnIndex++)
{
cCheck = quan.charAt(nIndex)
if (!IsDigit(cCheck))
{
alert("num must be a number")
return false
}
}
if( window.myform.Solution.value==""){alert("please input Solution")return false}
if( window.myform.shipdate.value==""){alert("please input shipdate")return false}
}
function IsDigit(cCheck)
{
return (('0'<=cCheck) &&(cCheck<='9'))
}
function selectitem()
{ document.all.myform.action="selectitem.asp"
document.all.myform.submit()
}
function submitt()
{ document.all.myform.action="addcustomer.asp?action=add"
document.all.myform.submit()
}
</script>
</head>
<% set ds=server.CreateObject("adodb.recordset")
ds.open "select * from customer",conn,3,3
if ds.eof then
tempno=0
else
do while not ds.eof
tempno=ds("customer")
ds.movenext
loop
end if
tempno=tempno+1
if len(tempno)<5 then
i=5-len(tempno)
for j=1 to i
tempno="0"&cstr(tempno)
next
end if
ds.close
%>
<body>
<p> </p>
<table width="80%" border="0" cellspacing="1" cellpadding="3" align="center" class="table">
<form name="myform" action="" method="post" onSubmit="return check()">
<tr>
<td width="29%" align="right">Date:</td><td width="71%"><input type="text" name="date" value="<%=formatdatetime(now(),2)%>"></td>
</tr>
<tr>
<td align="right">Customer NO.: </td>
<td><input type="text" name="customerno" value="<%=tempno%>"></td>
</tr>
<tr>
<td align="right">Customer name: </td>
<td><input name="Customername" type="text" id="Customername" value="<%=request("Customername")%>"></td>
</tr>
<tr>
<td align="right">Address:</td>
<td><input name="Address" type="text" id="Address" value="<%=request("Address")%>"></td>
</tr>
<tr>
<td align="right">Tel:</td>
<td><input name="Tel" type="text" id="Tel" value="<%=request("Tel")%>"></td>
</tr>
<tr>
<td align="right">Purchase date: </td>
<td><input name="Purchasedate" type="text" id="Purchasedate" onfocus=setday(this) value="<%=request("Purchasedate")%>"></td>
</tr>
<tr>
<td align="right">Purchase loaction: </td>
<td><input name="Purchaseloaction" type="text" id="Purchaseloaction" value="<%=request("Purchaseloaction")%>"></td>
</tr>
<tr>
<td align="right">invoice no:</td>
<td><input name="invoiceno" type="text" id="invoiceno" value="<%=request("invoiceno")%>"></td>
</tr>
<tr>
<td align="right">Purchase Product item: </td>
<td><select name="bigclass" onChange="selectitem()">
<option value="">select big class</option>
<% set rs1=server.CreateObject("adodb.recordset")
rs1.open "select * from bigclass",conn,3,3
do while not rs1.eof
%>
<option value="<%=rs1("bigclassid")%>" <%if request("bigclass")<>"" then if cint(trim(rs1("bigclassid")))=cint(trim(request("bigclass"))) then response.Write("selected") end if end if%>><%=rs1("bigclassname")%></option>
<% rs1.movenext
loop%>
</select>
<select name="smallclass" onChange="selectitem()">
<option value="">select small class</option>
<% if request("bigclass")<>"" then
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from smallclass where bigclassid="&cint(trim(request("bigclass")))&"",conn,3,3
do while not rs2.eof%>
<option value="<%=rs2("smallclassid")%>" <%if request("smallclass")<>"" then if cint(trim(rs2("smallclassid")))=cint(trim(request("smallclass"))) then response.Write("selected") end if end if%>><%=rs2("smallclassname")%></option>
<% rs2.movenext
loop
end if
%>
</select>
<select name="product" onChange="selectitem()">
<option value="">select product</option>
<%
if request("smallclass")<>"" then
set rs3=server.CreateObject("adodb.recordset")
rs3.open "select * from product where smallclassid="&cint(trim(request("smallclass")))&"",conn,3,3
do while not rs3.eof
%>
<option value="<%=rs3("productid")%>" <%if request("product")<>"" then if cint(trim(rs3("productid")))=cint(trim(request("product"))) then response.Write("selected") end if end if%>><%=rs3("productname")%></option>
<%rs3.movenext
loop
end if%>
</select>
<select name="item" onChange="selectitem()">
<option value="">select item</option>
<%
if request("product")<>"" then
set rs4=server.CreateObject("adodb.recordset")
rs4.open "select * from item where productid="&cint(trim(request("product")))&"",conn,3,3
do while not rs4.eof
%>
<option value="<%=rs4("itemid")%>"
<%if request("item")<>"" then
if cint(trim(rs4("itemid")))=cint(trim(request("item"))) then
itemn=trim(rs4("itemname"))
response.Write("selected")
end if
end if%>><%=rs4("ino")%></option>
<%rs4.movenext
loop
end if%>
</select><% if request("item")<>"" then response.Write(itemn) end if%></td>
</tr>
<tr>
<td align="right">replace number:</td>
<td><input name="num" type="text" id="num" value="<%=request("num")%>"></td>
</tr>
<tr>
<td align="right">Defective Reson: </td>
<td><select name="reason" onChange="selectitem()">
<option value="">select reason</option>
<% if request("product")<>"" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from product where productid="&cint(trim(request("product")))&"",conn,3,3
reason=rs("reason")
if reason<>"" then
k=cint(ubound(Split(reason,",")))
dsql="select * from reason where reasonid="&cint(split(reason)(0))
for i=1 to k
dsql=dsql&" or reasonid="&cint(split(reason)(i))
next
set ds=server.CreateObject("adodb.recordset")
ds.open dsql,conn,3,3
do while not ds.eof
%>
<option value="<%=ds("reasonid")%>" <%if request("reason")<>"" then if cint(trim(ds("reasonid")))=cint(trim(request("reason"))) then response.Write("selected") end if end if%>><%=ds("reason")%></option>
<%ds.movenext
loop
end if
end if%>
</select> </td>
</tr>
<tr>
<td align="right">Solution:</td>
<td><select name="Solution">
<option>select Solution</option>
<%
if request("reason")<>"" then
dim rs5,sql5
sql5="select * from Solution"
set rs5=server.CreateObject("adodb.recordset")
rs5.open sql5,conn,3,3
do while not rs5.eof%>
<option value="<%=rs5("Solutionid")%>" <% if rs5("reasonid")=cint(trim(request("reason"))) then response.Write("selected") end if%>><%=trim(rs5("Solution"))%></option>
<% rs5.movenext
loop
end if
%>
</select><% if request("item")<>"" then %><input type="button" value="check store" onClick="window.open('checkstore.asp?item=<%=request("item")%>','','width=400,height=200')"><% end if%></td>
</tr>
<tr>
<td align="right">Next Shipping Date: </td>
<td><input name="shipdate" type="text" id="shipdate" onfocus=setday(this) value="<%=request("shipdate")%>"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="button" value="submit" onClick="submitt()"></td>
</tr>
</form>
<% if request("product")<>"" then%>
<tr><td colspan="2" align="center">
<%set pic=server.CreateObject("adodb.recordset")
pic.open "select * from product where productid="&cint(trim(request("product")))&"",conn,3,3%>
<a href="<%=trim(pic("picurl"))%>" target="_blank"><img src="<%=trim(pic("picurl"))%>" border="0" width="200"></a>
</td></tr>
<% end if%>
</table>
</body>
</html>
<% if request("action")="add" then
if numb<0 then
response.Write("<script>alert('no enough store')selectitem()</script>")
else
set itemn=server.CreateObject("adodb.recordset")
set itemn=nothing
set rs6=server.CreateObject("adodb.recordset")
rs6.open "select * from customer",conn,3,3
rs6.addnew
rs6("customerno")=trim(request("customerno"))
rs6("customername")=trim(request("Customername"))
rs6("address")=trim(request("Address"))
rs6("tel")=trim(request("tel"))
rs6("ndate")=trim(request("date"))
rs6("purchasedate")=trim(request("Purchasedate"))
rs6("purchaseloaction")=trim(request("Purchaseloaction"))
rs6("invoiceno")=trim(request("invoiceno"))
rs6("productid")=trim(request("product"))
rs6("itemid")=trim(request("item"))
rs6("cnum")=cint(trim(request("num")))
rs6("reasonid")=trim(request("reason"))
rs6("solutionid")=trim(request("Solution"))
rs6("shipdate")=trim(request("shipdate"))
rs6("issend")=0
rs6.update
rs6.close
set rs6=nothing
response.Write("<script>alert('succeed')location.href='addcustomer.asp'</script>")
end if
end if
%>
中转页面 selectitem.asp
<%
Customername=request("Customername")
Address=request("Address")
Tel=request("Tel")
Purchasedate=request("Purchasedate")
Purchaseloaction=request("Purchaseloaction")
shipdate=request("shipdate")
invoiceno=request("invoiceno")
bigclass=request("bigclass")
smallclass=request("smallclass")
product=request("product")
item=request("item")
reason=request("reason")
num=request("num")
response.Redirect("addcustomer.asp?Customername="&Customername&"&bigclass="&bigclass&"&smallclass="&smallclass&"&product="&product&"&item="&item&"&Address="&Address&"&Tel="&Tel&"&Purchasedate="&Purchasedate&"&Purchaseloaction="&Purchaseloaction&"&invoiceno="&invoiceno&"&shipdate="&shipdate&"&reason="&reason&"&num="&num&"")
%>
最好是用ajax,无页面刷新,不过俺没试过
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)