使用AjaxPro开发四级无刷新联动下拉框
开发环境 VS.NET 2005 C# Oracle AjaxPro
最近忙没时间详细解释,先把通用的源码贴出自己看。
出于对性能的考虑,把省市两级写成JS数组,把县区(镇)两级写在 Oracle 里。通过 JS 触发 C# 去读取数据库,然后将数据回传给 JS ,再绑定显示。
操作 <select> 采用更通用的 createElement() 而没有使用 options.add()
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Area.aspx.cs" Inherits="Area" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head runat="server">
<title>地区</title>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td>
<select id="SF">
<option selected="selected">—请选择—</option>
</select>
</td>
<td>
<select id="CS">
<option selected="selected">—请选择—</option>
</select>
</td>
<td>
<select id="Xian">
<option selected="selected">—请选择—</option>
</select>
</td>
<td>
<select id="Zhen">
<option selected="selected">—请选择—</option>
</select>
</td>
</tr>
</table>
<script type="text/javascript">
var aDQ=new Array();
aDQ[0]=["11","北京","0","bj"];
aDQ[1]=["12","天津","0","tj"];
aDQ[2]=["13","河北","0","hb"];
aDQ[3]=["14","山西","0","shang"];
aDQ[4]=["15","内蒙古","0","nmg"];
aDQ[5]=["21","辽宁","0","ln"];
aDQ[6]=["22","吉林","0","jl"];
aDQ[7]=["23","黑龙江","0","hlj"];
aDQ[8]=["31","上海","0","sh"];