首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

从数据库中取国家,省份,城市的三级联动,可每次需重新刷新页面。可不可以不需要刷新页面。该怎么处理

2012-02-14 
从数据库中取国家,省份,城市的三级联动,可每次需重新刷新页面。可不可以不需要刷新页面。如题。ifpa_pr_city

从数据库中取国家,省份,城市的三级联动,可每次需重新刷新页面。可不可以不需要刷新页面。
如题。
  if   pa_pr_city   <>   " "   then
      sqlstr   =   "select   *   from   li_district   where   li_city_code= "   &transtr(pa_pr_city)  
    set   rs=sysGetRs(sqlstr,cn,0,false)
      strdistrict   =   " <option   value= ' '   selected   > </option> "
      do   while   not   rs.eof
if   cstr(rs( "li_district_code "))   =   cstr(pa_district_code)   then
      strdistrict   =   strdistrict   &   " <option   value= ' "   &   rs( "li_district_code ")   &   " '   selected> "   &   rs( "li_district_name_lcl ")   &   " </option> "
  else
      strdistrict   =   strdistrict   &   " <option   value= ' "   &   rs( "li_district_code ")   &   " '> "   &   rs( "li_district_name_lcl ")   &   " </option> "
  end   if
      rs.movenext
      loop
      rs.close
  end   if


城市: <select   onChange= "changecity(this.value) "   name= "pa_pr_city "   style= "width:60px; "   nonull= "yes ">
    <%=strcity%>
</select>

[解决办法]
用脚本来实现
<form id= "form1 ">
<select name= "aa " onchange= "return aa_onchange() "> </select>
<select name= "bb "> </select>
</form>

<script id= "Zw " type= "text/javascript "> </script>
<SCRIPT LANGUAGE=javascript>
function aa_onchange(i) {
Zw.src = "Zw.asp ";
}
</SCRIPT>

在zw.asp中查询出需要的数据,以循环写入
for ....
itemStr = "var item=new Option( ' " & RS( "ZwName ") & " ', " & RS( "ID ") & "); "
itemStr = itemStr & "form1.bb " & SelID & ".add(item); "
Response.Write itemStr
next
[解决办法]
<form id= "myform " name= "myform " method= "post " action= "Modi_pro.asp ">
<tr>
<td height= "20 " colspan= "5 " nowrap= "nowrap " bgcolor= "#CACACA "> 产品查询: <strong> 一级:
<select name= "class1 " onChange= "redirect1(this.options.value); " >
<option> 请选择类别 </option>
<%Set RS1=fSelect( "View_Class ", "DISTINCT class1_id,class1 ", "1=1 ")
if rs1.eof then %>
<option> 没有设置类别 </option>
<% else
do while not rs1.eof %>
<option value= " <%=trim(rs1( "class1_id "))%> "> <%=trim(rs1( "class1 "))%> </option>
<% rs1.movenext
loop
end if
%>
</select>
二级:
<select name= "class2 " onChange= "redirect2(this.options.value); ">


<option> 请选择类别 </option>
</select>
&nbsp;三级:
<select name= "class3 " onChange= "redirect3(this.options.value); ">
<option> 请选择类别 </option>
</select>
四级:
<select name= "class4 ">
<option> 请选择类别 </option>
</select>
</strong> <br />
产品名称:
<input name= "pro_name " type= "text " id= "pro_name " size= "12 " />
&nbsp;产品型号:
<input name= "pro_xh " type= "text " id= "pro_xh " size= "12 " />
&nbsp;添加日期:
<input name= "addtime " type= "text " id= "addtime " size= "12 " />
<input type= "submit " name= "Submit " value= " Go " /> </td>
</tr>
</form>

<script>
<!--
function redirect1(x)
{
var i=1;
var temp=document.myform.class2;
temp.options[i]=new Option( "请选择类别 ");
for (var m=temp.options.length-1;m> 0;m--)
temp.options[m]=null;
<%
Set RS2=fSelect( "View_Class ", "DISTINCT class2_id,class2,class2_parentid ", "1=1 ")
while not rs2.eof
%>
if( <%response.write(rs2(2))%> ==(x))
{
temp.options[i]=new Option( " <%=trim(rs2(1))%> ", " <%=rs2(0)%> ");
i=i+1;
}
else
{
temp.options[i]=null;
}
<%
rs2.movenext
wend
%>
}


function redirect2(x)
{
var i=1;
var temp=document.myform.class3;
temp.options[i]=new Option( "请选择类别 ");
for (var m=temp.options.length-1;m> 0;m--)
temp.options[m]=null;
<%
Set RS3=fSelect( "View_Class ", "DISTINCT class3_id,class3,class3_parentid ", "1=1 ")
while not rs3.eof
%>
if( <%response.write(rs3(2))%> ==(x))
{
temp.options[i]=new Option( " <%=trim(rs3(1))%> ", " <%=rs3(0)%> ");
i=i+1;}
else
{
temp.options[i]=null;
}
<%
rs3.movenext
wend
%>
}

function redirect3(x)
{
var i=0;
var temp=document.myform.class4;
temp.options[i]=new Option( "请选择类别 ");
for (var m=temp.options.length-1;m> 0;m--)
temp.options[m]=null;
<%
Set RS4=fSelect( "View_Class ", "DISTINCT class4_id,class4,class4_parentid ", "1=1 ")
while not RS4.eof
%>
if( <%response.write(rs4(2))%> ==(x))
{
temp.options[i]=new Option( " <%=trim(rs4(1))%> ", " <%=rs4(0)%> ");
i=i+1;}
else
{
temp.options[i]=null;
}
<%
rs4.movenext
wend
%>
}
//-->
</script>
[解决办法]
用AJAX..

那么就把数据放数组里..用JS来实现!
[解决办法]
如果不刷新一下的话,可能第一次打开要很长时间,尤其是你要做全国性的话,一下上几百K的数据.如果是全球性的话,那就不用问了....太庞大的数据写进JS里,好象目前没那个网站这么做法.....

热点排行