无刷新二级联动
我想做一个无刷新的二级联动,就是当选择一级的值时,不用刷新页面就可以出现第二级的相关内容,我做了个二级联动,可是他每选一次就会刷新一次页面,那样的话就会把前面表格中填的值...
我想做一个无刷新的二级联动,就是当选择一级的值时,不用刷新页面就可以出现第二级的相关内容,我做了个二级联动,可是他每选一次就会刷新一次页面,那样的话就会把前面表格中填的值清除掉
我的二级联动代码如下,哪位帮我改成无刷新的二级联动呀(要从数据库中搜索值)
<%
dim cid,coid
cid = request("cid") 'cid 大类id
coid = request("coid") 'coid 中类id
'set rs=server.createobject("adodb.recordset")
sql = "select * from FittingsType" '表一 大类表
rs.open sql,conn,1,1
strOption1 = "<option value='' selected >=请选择分类=</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(cid) then
strOption1 = strOption1 & "<option value='" & rs("id") & "' selected>" & rs("typename") & "</option>"
else
strOption1 = strOption1 & "<option value='" & rs("id") & "'>" & rs("typename") & "</option>"
end if
rs.movenext
loop
rs.close
if cid <> "" then
sql = "select * from mode where typeid='"&cid&"'" '表二 中类表 bid==表一中的id
rs.open sql,conn,1,1
strOption2 = "<option value='' selected >=请选择型号=</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(coid) then
strOption2 = strOption2 & "<option value='" & rs("id") & "' selected>" & rs("mode") & "</option>"
else
strOption2 = strOption2 & "<option value='" & rs("id") & "'>" & rs("mode") & "</option>"
end if
rs.movenext
loop
rs.close
end if
%>
<select onchange="changeb(this.value)" name="cid"><%=strOption1%></select>
<select onchange="change(this.value)" name="coid"><%=strOption2%></select>
<script language="javascript">
<!--
function changeb(cid){
location.assign("Wf_login.asp?action=s_s&cid=" + cid);
}
-->
</script> 展开
我的二级联动代码如下,哪位帮我改成无刷新的二级联动呀(要从数据库中搜索值)
<%
dim cid,coid
cid = request("cid") 'cid 大类id
coid = request("coid") 'coid 中类id
'set rs=server.createobject("adodb.recordset")
sql = "select * from FittingsType" '表一 大类表
rs.open sql,conn,1,1
strOption1 = "<option value='' selected >=请选择分类=</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(cid) then
strOption1 = strOption1 & "<option value='" & rs("id") & "' selected>" & rs("typename") & "</option>"
else
strOption1 = strOption1 & "<option value='" & rs("id") & "'>" & rs("typename") & "</option>"
end if
rs.movenext
loop
rs.close
if cid <> "" then
sql = "select * from mode where typeid='"&cid&"'" '表二 中类表 bid==表一中的id
rs.open sql,conn,1,1
strOption2 = "<option value='' selected >=请选择型号=</option>"
do while not rs.eof
if cstr(rs("id")) = cstr(coid) then
strOption2 = strOption2 & "<option value='" & rs("id") & "' selected>" & rs("mode") & "</option>"
else
strOption2 = strOption2 & "<option value='" & rs("id") & "'>" & rs("mode") & "</option>"
end if
rs.movenext
loop
rs.close
end if
%>
<select onchange="changeb(this.value)" name="cid"><%=strOption1%></select>
<select onchange="change(this.value)" name="coid"><%=strOption2%></select>
<script language="javascript">
<!--
function changeb(cid){
location.assign("Wf_login.asp?action=s_s&cid=" + cid);
}
-->
</script> 展开
展开全部
<%
dim cid,coid
cid=Request("cid")
coid=Request("coid")
Set rs=CreateObject("adodb.recordset")
rs.open "Select * from FittingsType",conn,1,1 '获取大类数据
strOption1 = " <option value= ''>=请选择分类= </option >"
do while not rs.eof
if cstr(rs("id")) = cstr(cid) then
strOption1 = strOption1 & " <option value='" & rs("id") & "' selected >" & rs("typename") & "</option >"
else
strOption1 = strOption1 & " <option value= '" & rs("id") & "'>" & rs("typename") & "</option >"
end if
rs.movenext
loop
rs.close
rs.open "Select * from mode",conn,1,1 '获取小类数据
%>
<script language="javascript">
<!--
//先定义大类和小类数组
var minclass=Array();
<%
js=0
do while not rs.eof%>
minclass[<%=js%>]=new Array("<%=rs("id")%>","<%=rs("mode")%>","<%=rs("typeid")%>");
<%rs.movenext
js=js+1
loop
rs.Close
Set rs=nothing
Conn.Close
Set Conn=nothing
%>
function changesmall()
{
var indexvalue=document.all("cid").options[document.all("cid").selectedIndex].value;
var j=0;
document.all("coid").length = 0;
document.all("coid").options[0]=new Option("=请选择型号=","0");
for(i=0;i<minclass.length;i++)
{
if(minclass[i][2]==indexvalue)
{
document.all("coid").options[document.all("coid").length]=new Option(minclass[i][1],minclass[i][0]);
}
}
}
function setvalue(cvalue)
{
var m,n;
m=document.all("coid").length;
for(n=0;n<m;n++)
{
if(document.all("coid").options[n].value==cvalue)
{
document.all("coid").selectedIndex=n;
return;
}
}
}
-->
</script>
<script language="javascript" defer="defer">
setvalue("<%=coid%>");
</script>
<select onchange="changesmall()" name="cid" > <%=strOption1%> </select >
<select name="coid">=请选择型号=</select>
dim cid,coid
cid=Request("cid")
coid=Request("coid")
Set rs=CreateObject("adodb.recordset")
rs.open "Select * from FittingsType",conn,1,1 '获取大类数据
strOption1 = " <option value= ''>=请选择分类= </option >"
do while not rs.eof
if cstr(rs("id")) = cstr(cid) then
strOption1 = strOption1 & " <option value='" & rs("id") & "' selected >" & rs("typename") & "</option >"
else
strOption1 = strOption1 & " <option value= '" & rs("id") & "'>" & rs("typename") & "</option >"
end if
rs.movenext
loop
rs.close
rs.open "Select * from mode",conn,1,1 '获取小类数据
%>
<script language="javascript">
<!--
//先定义大类和小类数组
var minclass=Array();
<%
js=0
do while not rs.eof%>
minclass[<%=js%>]=new Array("<%=rs("id")%>","<%=rs("mode")%>","<%=rs("typeid")%>");
<%rs.movenext
js=js+1
loop
rs.Close
Set rs=nothing
Conn.Close
Set Conn=nothing
%>
function changesmall()
{
var indexvalue=document.all("cid").options[document.all("cid").selectedIndex].value;
var j=0;
document.all("coid").length = 0;
document.all("coid").options[0]=new Option("=请选择型号=","0");
for(i=0;i<minclass.length;i++)
{
if(minclass[i][2]==indexvalue)
{
document.all("coid").options[document.all("coid").length]=new Option(minclass[i][1],minclass[i][0]);
}
}
}
function setvalue(cvalue)
{
var m,n;
m=document.all("coid").length;
for(n=0;n<m;n++)
{
if(document.all("coid").options[n].value==cvalue)
{
document.all("coid").selectedIndex=n;
return;
}
}
}
-->
</script>
<script language="javascript" defer="defer">
setvalue("<%=coid%>");
</script>
<select onchange="changesmall()" name="cid" > <%=strOption1%> </select >
<select name="coid">=请选择型号=</select>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询