<%@ Page Language="C#" AutoEventWireup="true" CodeFile="oec2003index.aspx.cs"
Inherits="ajax_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>无标题页</title>
<script type="text/javascript">
var xmlhttp;
function getData() {
var ddlpro = document.getElementById("ddlPro");
var pro = ddlpro.options[ddlpro.selectedIndex].innerText;
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = statechange;
xmlhttp.Open("GET", "oec2003datapage.aspx?pro=" + pro, true);
xmlhttp.Send();
}
function statechange() {
if (xmlhttp.readystate == 4) {
if (xmlhttp.status == 200) {
FillData(xmlhttp.responseText);
}
}
}
function FillData(strcity) {
document.getElementById("ddlCity").options.length = 0;
var indexofcity;
var city;
while (strcity.length > 0) {
indexofcity = strcity.indexOf(",");
if (indexofcity > 0) {
city = strcity.substring(0, indexofcity);
strcity = strcity.substring(indexofcity + 1);
document.getElementById("ddlCity").add(new Option(city, city));
}
else {
document.getElementById("ddlCity").add(new Option(strcity, strcity));
break;
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table width="700px" border="1" cellpadding="5" cellspacing="0">
<tr>
<td colspan="2" align="center">
ajax方法实现刷新
</td>
</tr>
<tr>
<td>
选择省份:
</td>
<td>
<select id="ddlPro" style="width: 201px">
<option value="湖北">湖北</option>
<option value="河北">河北</option>
<option value="广东">广东</option>
<option value="河南">河南</option>
</select>
<input id="btnQuery" type="button" value=" 查询" onclick="getData()" />
</td>
</tr>
<tr>
<td>
城市:
</td>
<td>
<asp:DropDownList ID="ddlCity" runat="server" Width="201px">
</asp:DropDownList>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>