ASP.NET下的Ajax二级联动,不能在FIREFOX下使用啊!!在线等!

fw918 2007-04-18 11:08:36
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>

<!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 runat="server">
<title>DropDownList</title>
<script language="javascript">

function load(provinceid)
{
var drp2 = document.getElementById("DropDownList2");
var len=drp2.options.length;
while(len>0)
{
drp2.options.remove(0);
len=drp2.options.length;
}

var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP"); //发送请求
var oDoc = new ActiveXObject("MSXML2.DOMDocument"); //响应结果

if(provinceid==null)
{
var provinceid=document.getElementById("DropDownList1").value;
}

oHttpReq.open("post","index2.aspx?pid="+provinceid, false);
oHttpReq.send("");

result = oHttpReq.responseText;
oDoc.loadXML(result);

items = oDoc.selectNodes("//Cate_Child/Table");
for (var item = items.nextNode();item;item = items.nextNode())
{ 
var city = item.selectSingleNode("value").nodeTypedValue;
var id = item.selectSingleNode("code").nodeTypedValue;
var newOption = document.createElement("OPTION");
newOption.text = city;
newOption.value = id;
drp2.options.add(newOption);
} 
}

</script>


</head>
<body>
<form id="form1" runat="server">
<div><asp:DropDownList id="DropDownList1" style="Z-INDEX: 101; LEFT: 188px; POSITION: absolute; TOP: 32px" runat="server" DataSourceID="SqlDataSource1" DataTextField="Value" DataValueField="Code"></asp:DropDownList>
<asp:DropDownList id="DropDownList2" style="Z-INDEX: 102; LEFT: 276px; POSITION: absolute; TOP: 32px" runat="server" DataSourceID="SqlDataSource2" DataTextField="Value" DataValueField="Code"></asp:DropDownList></div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SqlDataSource1 %>"
SelectCommand="SELECT code,value FROM [DD_PROVINCE] where Right(code,2)='00'"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SqlDataSource2 %>"
SelectCommand="SELECT code,value FROM [DD_PROVINCE] where code='0100'"></asp:SqlDataSource>
</form>
</body>
</html>
...全文
424 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
fw918 2007-04-19
  • 打赏
  • 举报
回复
讲的真详细啊,谢谢你的回答,高手,以后还要多请教你,我是AJAX新手,当然也是JS的新手
fw918 2007-04-18
  • 打赏
  • 举报
回复
杂九没有人回答啊?分数不够可以加的啊

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧