无刷新三级联动菜单从数据库获取数据(适用于fir
系统
1957 0
表单叶面
<
script
language
="javascript"
src
="include/selectoption.js"
></
script
>
<
select
name
="privceid"
id
="privceid"
onchange
="editnextselect(this,'cityid');"
>
<
option
value
="-1"
>
请选择
</
option
>
</
select
>
省
<
select
name
="cityid"
id
="cityid"
onchange
="editnextselect(this,'county');"
>
<
option
value
="-1"
>
请选择
</
option
>
</
select
>
市
<
select
name
="county"
id
="county"
>
<
option
value
="-1"
>
请选择
</
option
>
</
select
>
区/县
<
script
language
="javascript"
>
...
var
privceid
=
"
<%=privceid%>
"
;
var
cityid
=
"
<%=cityid%>
"
;
var
county
=
"
<%=county%>
"
;
getdatelist(
'
&pid=
'
,privceid,
'
privceid
'
);
if
(cityid
!=
""
)
...
{getdatelist(
'
&pid=
'
+
privceid,cityid,
'
cityid
'
);}
if
(county
!=
""
)
...
{getdatelist(
'
&pid=
'
+
cityid,county,
'
county
'
);}
function
editnextselect(obj,nexselid)
...
{
if
(nexselid
==
'
cityid
'
)
...
{
selvalue
=
cityid;
}
else
...
{
selvalue
=
county;
}
var
pid
=
obj.options[obj.selectedIndex].value;
if
(pid
!=
null
)
...
{
getdatelist(
'
&pid=
'
+
pid,selvalue,nexselid);
}
}
</
script
>
js包含叶面
//
JavaScriptDocument
function
InitAjax()
...
{
var
ajax
=
false
;
try
...
{ajax
=
new
ActiveXObject(
"
Msxml2.XMLHTTP
"
);}
catch
(e)
...
{
try
...
{ajax
=
new
ActiveXObject(
"
Microsoft.XMLHTTP
"
);}
catch
(E)
...
{ajax
=
false
;}
}
if
(
!
ajax
&&
typeof
XMLHttpRequest
!=
'
undefined
'
)
...
{ajax
=
new
XMLHttpRequest();}
return
ajax;
}
function
datexml(url,value)
...
{
var
number
=
Math.random();
var
url
=
url
+
"
?qaaq=
"
+
number
+
value;
var
ajax
=
InitAjax();
ajax.open(
"
GET
"
,url,
false
);
ajax.send(
null
);
//
ajax.onreadystatechange=function(){}
if
(ajax.readyState
==
4
&&
ajax.status
==
200
)
...
{
return
ajax.responseText;}
}
function
getdatelist(values,selvalues,SelectName)
...
{
var
getdate
=
datexml(
"
include/xmlgetp_c_c.asp
"
,values);
if
(getdate)
...
{
if
(getdate
!=
"
wrong
"
&&
getdate
!=
"
no
"
)
...
{
var
objSelect
=
document.getElementById(SelectName);
objSelect.options.length
=
1
;
var
datearray
=
getdate.split(
"
$
"
);
for
(i
=
0
;i
<
datearray.length
-
1
;i
++
)
...
{
var
op
=
window.document.createElement(
"
option
"
);
op.value
=
datearray[i].split(
"
|
"
)[
0
];
op.innerHTML
=
unescape(datearray[i].split(
"
|
"
)[
1
]);
objSelect.appendChild(op);
}
if
(selvalues
!=
""
)
...
{
for
(i
=
0
;i
<
objSelect.options.length;i
++
)
...
{
if
(objSelect.options[i].value
==
selvalues)
...
{
objSelect.options[i].selected
=
true
;
break
;
}
}
}
}
}
}
读取数据库叶面
<
!
--
#includefile
=
"
dbconn.asp
"
-->
<
%
pid
=
request.querystring(
"
pid
"
)
if
pid
<>
""
then
if
isnumeric
(pid)
=
false
then
response.write
"
wrong
"
end
if
end
if
if
pid
=
""
then
sql
=
"
selectzipcode,zipnamefromZIPCODEINFOwhereparentzipisnull
"
else
sql
=
"
selectzipcode,zipnamefromzipcodeinfowhereparentzip='
"
&
pid
&
"
'
"
end
if
call
dbopen
set
rs
=
conn.execute(sql)
if
not
rs.eof
then
do
while
not
rs.eof
response.writers(
"
zipcode
"
)
&
"
|
"
&
escape(rs(
"
zipname
"
))
&
"
$
"
rs.movenext
loop
else
response.write
"
no
"
end
if
set
rs
=
nothing
call
dbclose
%
>
无刷新三级联动菜单从数据库获取数据(适用于firefox和ie)
更多文章、技术交流、商务合作、联系博主
微信扫码或搜索:z360901061
微信扫一扫加我为好友
QQ号联系: 360901061
您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。
【本文对您有帮助就好】元