现在的位置: 首页 > 综合 > 正文

三级无刷新联动(添加 编辑)

2013年02月03日 ⁄ 综合 ⁄ 共 6909字 ⁄ 字号 评论关闭

三级无刷新联动(添加)
<%
dim conn
dim rs
dim sql
dim count
dim rs1
dim sql1
sql = "SELECT * FROM lei_area_table where paterid<>0 order by ordertime desc"
set rs = conn.execute(sql)
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
        <%
        count = 0
        do while not rs.eof
        %>
subcat[<%=count%>] = new Array("<%= trim(rs("name"))%>","<%= trim(rs("paterid"))%>","<%= trim(rs("id"))%>");
        <%
        count = count + 1
        rs.movenext
        loop
        rs.close
        set rs=nothing
        %>
onecount=<%=count%>;

function changelocation(locationid)
    {
    document.newform.city.length = 0;

    var locationid=locationid;
    var i;
    document.newform.city.options[0] = new Option('====所在城市====','');
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            {
   //alert(subcat[i][1]);
                document.newform.city.options[document.newform.city.length] = new Option(subcat[i][0], subcat[i][2]);
            }       
        }
       
    }   
</script>
<%sql ="select * from lei_hotel where id is not null and flag=1 order by ser desc"
set rs = conn.execute(sql)
%>
<script language = "JavaScript">
var onecounthotel;
onecounthotel=0;
subcathotel = new Array();
        <%
        count = 0
        do while not rs.eof
        %>
subcathotel[<%=count%>] = new Array("<%= trim(rs("hotel"))%>","<%= trim(rs("price"))%>","<%= trim(rs("id"))%>");
        <%
        count = count + 1
        rs.movenext
        loop
        rs.close
        set rs=nothing
        %>
onecounthotel=<%=count%>;

function changehotel(locationid)
    {
    document.newform.roomhotel.length = 0;

    var locationid=locationid;
    var i;
    document.newform.roomhotel.options[0] = new Option('====所在城市====','');
    for (i=0;i < onecounthotel; i++)
        {
            if (subcathotel[i][1] == locationid)
            {
   //alert(subcat[i][1]);
                document.newform.roomhotel.options[document.newform.roomhotel.length] = new Option(subcathotel[i][0], subcathotel[i][2]);
            }       
        }
       
    }   
</script>

<select name="province" class="i1" onChange="changelocation(document.newform.province.options[document.newform.province.selectedIndex].value)">
     <option value="">请选择省</option>
                <%
       
        sql1 = "SELECT * FROM lei_area_table where paterid=0 order by ordertime desc"
        set rs1 = conn.Execute (sql1)
        do while not rs1.eof
        %>
                <option value="<%=trim(rs1("id"))%>"><%=trim(rs1("name"))%></option>
                <%
        rs1.movenext
        loop
        rs1.close
        set rs1 = nothing
        %>
              </select>
              <select name="city" class="i1" onChange="changehotel(document.newform.city.options[document.newform.city.selectedIndex].value)">
                <option value="">==所在城市==</option>
              </select>
              <font color="#FF0000">*</font>
              <Select NAME="roomhotel" CLASS="i1" style="font-family: 新细明体, 宋体, Arial; font-size: 14px; height: 23; background-color: #f3f3f3; width: 136; border: 1 solid black"  onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" size="1">
                <option value="" selected>请选择所属酒店</option>
    </select>

三级无刷新联动(编辑)
<%
dim conn
dim rs
dim sql
dim count
dim rs1
dim sql1
sql = "SELECT * FROM lei_area_table where paterid<>0 order by ordertime desc"
set rs = conn.execute(sql)
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
        <%
        count = 0
        do while not rs.eof
        %>
subcat[<%=count%>] = new Array("<%= trim(rs("name"))%>","<%= trim(rs("paterid"))%>","<%= trim(rs("id"))%>");
        <%
        count = count + 1
        rs.movenext
        loop
        rs.close
        set rs=nothing
        %>
onecount=<%=count%>;

function changelocation(locationid)
    {
    document.newform.city.length = 0;
 //alert(document.newform.cityselect.value);
    var locationid=locationid;
    var i;
    document.newform.city.options[0] = new Option('====所在城市====','');
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == locationid)
            {
   //alert(subcat[i][1]);
                document.newform.city.options[document.newform.city.length] = new Option(subcat[i][0], subcat[i][2]);
            }       
        }
  for (i=0;i<document.newform.city.length;i++){
  //alert(document.myform.smalllocation[i].value);
  if (document.newform.city[i].value==document.newform.cityselect.value){
  document.newform.city[i].selected=true;
  }
  }        
    }   
</script>
<%sql ="select * from lei_hotel where id is not null and flag=1 order by ser desc"
set rs = conn.execute(sql)
%>
<script language = "JavaScript">
var onecounthotel;
onecounthotel=0;
subcathotel = new Array();
        <%
        count = 0
        do while not rs.eof
        %>
subcathotel[<%=count%>] = new Array("<%= trim(rs("hotel"))%>","<%= trim(rs("price"))%>","<%= trim(rs("id"))%>");
        <%
        count = count + 1
        rs.movenext
        loop
        rs.close
        set rs=nothing
        %>
onecounthotel=<%=count%>;

function changehotel(locationid)
    {
    document.newform.roomhotel.length = 0;

    var locationid=locationid;
    var i;
    document.newform.roomhotel.options[0] = new Option('====请选择所属酒店====','');
    for (i=0;i < onecounthotel; i++)
        {
            if (subcathotel[i][1] == locationid)
            {
   //alert(subcat[i][1]);
                document.newform.roomhotel.options[document.newform.roomhotel.length] = new Option(subcathotel[i][0], subcathotel[i][2]);
            }       
        }
  for (i=0;i<document.newform.roomhotel.length;i++){
  //alert(document.myform.smalllocation[i].value);
  if (document.newform.roomhotel[i].value==document.newform.hotelselect.value){
  document.newform.roomhotel[i].selected=true;
  }
  }        
    }   
</script>

<select name="province" class="i1" onChange="changelocation(document.newform.province.options[document.newform.province.selectedIndex].value)">
     <option value="">请选择省</option>
                <%
       
        sql1 = "SELECT * FROM lei_area_table where paterid=0 order by ordertime desc"
        set rs1 = conn.Execute (sql1)
        do while not rs1.eof
        %>
                <option value="<%=trim(rs1("id"))%>" <% if rs("provinceid")=rs1("id") then response.Write("selected")%>><%=trim(rs1("name"))%></option>
                <%
        rs1.movenext
        loop
        rs1.close
        set rs1 = nothing
        %>
              </select>
     <input name="cityselect" type="hidden" id="cityselect" value="<%=rs("cityid")%>">
              <select name="city" class="i1" onChange="changehotel(document.newform.city.options[document.newform.city.selectedIndex].value)">
                <option value="">==所在城市==</option>
              </select> 
          <input name="hotelselect" type="hidden" id="hotelselect" value="<%=rs("roomhotel")%>">         
     <Select NAME="roomhotel" CLASS="i1" style="font-family: 新细明体, 宋体, Arial; font-size: 14px; height: 23; background-color: #f3f3f3; width: 136; border: 1 solid black"  onMouseOver = "this.style.backgroundColor = '#E5F0FF'" onMouseOut = "this.style.backgroundColor = ''" size="1">   
                <option value="">请选择所属酒店</option>  
                </select> 

<script LANGUAGE="javascript">
    changelocation(document.newform.province.options[document.newform.province.selectedIndex].value);
 changehotel(document.newform.city.options[document.newform.city.selectedIndex].value);
</script>

抱歉!评论已关闭.