js的2级联动 有个分类表(如手表、香水、箱包等),还有个品牌表(如古驰、巴宝莉等),一个品牌可以在多个类型下在选择分类后,出现分类下面的品牌,注意数据都是从数据库读取的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那你就从数据库中读取贝我一般是在后台写代码!第一步,找到你的所有品牌,放在第一个dropdownlist中在根据选择第一个dropdownList的Id去查找,来显示在第二个dropdownList当中的值!这个两级联动很简单的哎!你代码写出来,直接绑定一下就可以了啊! 前台 <!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> <title></title> <script language="javascript" type="text/javascript"> var xhr; var num; function CreateXmlHttp() { if (window.ActiveXObject) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } else { xhr = new XMLHttpRequest(); } } function SendReq() { CountryID = document.getElementById("Country").value; CreateXmlHttp(); var url = "Test.ashx?CountryID=" + CountryID; xhr.open("GET", url, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var result = xhr.responseText; document.getElementById("City").innerHTML = result; } } xhr.send(null); } </script></head><body> <select id="Country" onchange="SendReq()"> <option value="1">中国</option> <option value="2">美国</option> </select> <span id="City"></span></body> </html>后台<%@ WebHandler Language="C#" Class="Test" %>using System;using System.Text;using System.Web;using System.Data;using System.Data.SqlClient;public class Test : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; StringBuilder builder = new StringBuilder(); if (context.Request.QueryString["CountryID"]!=null) { builder.Append("<select>"); int countryID = int.Parse(context.Request.QueryString["CountryID"]); string sqlCn = "Data Source=.;Initial Catalog=Test;Integrated Security=True;"; //根据国家编号查询数据表中的城市编号,城市名 string sqlCmd = "select CityID,CityName from City Where CountryID="+countryID; //根据前台的请求 查询需要的数据 using (SqlConnection cn = new SqlConnection(sqlCn)) { SqlCommand cmd = new SqlCommand(sqlCmd,cn); cn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { builder.Append("<option value='"+dr["CityID"].ToString()+"'>"+dr["CityName"].ToString()+"</option>"); } dr.Close(); builder.Append("</select>"); } } //返回前台请求的数据 context.Response.Write(builder.ToString()); } public bool IsReusable { get { return false; } }} 上个帖有给你回过了http://blog.csdn.net/porschev/archive/2010/10/15/5943579.aspx可以把这个改一下。。但是形式己经出来了 关于修改SqlDataReader的问题 frameset 垂直滚动条 如何获取网站里一个文件及他的文件夹名 关于如何取得IBatisNet的sql语句的问题,急急急!!! freetextbox中提交的内容不能包括 ' asp.net sqlserver 如何用一段代码来实现查询功能 ·DataSet.Tables[0].Select()是什么意思? 请教log4net配置问题 大家帮忙看看 水晶报表问题 小妹先谢过了 操作DataTime问题? 弹出登录窗口 ajax实现 进行验证的问题 一个简单的SQL递归函数,用于读取文章栏目,提示列名无效
第一步,找到你的所有品牌,放在第一个dropdownlist中
在根据选择第一个dropdownList的Id去查找,来显示在第二个dropdownList当中的值!这个两级联动很简单的哎!
你代码写出来,直接绑定一下就可以了啊!
<!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>
<title></title>
<script language="javascript" type="text/javascript">
var xhr;
var num;
function CreateXmlHttp() {
if (window.ActiveXObject) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
xhr = new XMLHttpRequest();
}
}
function SendReq() {
CountryID = document.getElementById("Country").value;
CreateXmlHttp();
var url = "Test.ashx?CountryID=" + CountryID;
xhr.open("GET", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var result = xhr.responseText;
document.getElementById("City").innerHTML = result;
}
}
xhr.send(null);
}
</script>
</head>
<body>
<select id="Country" onchange="SendReq()">
<option value="1">中国</option>
<option value="2">美国</option>
</select>
<span id="City"></span>
</body>
</html>
后台
<%@ WebHandler Language="C#" Class="Test" %>using System;
using System.Text;
using System.Web;
using System.Data;
using System.Data.SqlClient;public class Test : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/plain";
StringBuilder builder = new StringBuilder();
if (context.Request.QueryString["CountryID"]!=null)
{
builder.Append("<select>");
int countryID = int.Parse(context.Request.QueryString["CountryID"]);
string sqlCn = "Data Source=.;Initial Catalog=Test;Integrated Security=True;";
//根据国家编号查询数据表中的城市编号,城市名
string sqlCmd = "select CityID,CityName from City Where CountryID="+countryID;
//根据前台的请求 查询需要的数据
using (SqlConnection cn = new SqlConnection(sqlCn))
{
SqlCommand cmd = new SqlCommand(sqlCmd,cn);
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
builder.Append("<option value='"+dr["CityID"].ToString()+"'>"+dr["CityName"].ToString()+"</option>");
}
dr.Close();
builder.Append("</select>");
}
}
//返回前台请求的数据
context.Response.Write(builder.ToString());
}
public bool IsReusable
{
get {
return false;
}
}}
上个帖有给你回过了http://blog.csdn.net/porschev/archive/2010/10/15/5943579.aspx可以把这个改一下。。但是形式己经出来了