1、效果图

2、前端

@{
ViewBag.Title = "Index";
Layout = null; @*自动筛选下拉框*@
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<link href="~/Content/EasyUI/themes/default/easyui.css" rel="stylesheet" />
<script src="~/Content/EasyUI/jquery.easyui.min.js"></script> } <table style="width:40%; margin:auto;" class="mys-table2">
<tr>
<td colspan="3" style="text-align:center;">
检索的级联形式(好用)
</td>
</tr>
<tr>
<td>
<input id="sheng" class="easyui-combobox" style="width:100px"
data-options="{
url:'/Home/GetProvince',
method:'get',
valueField:'id',
textField:'text',
onSelect:function(region){
$('#shi').combobox('clear'); //清除原有项目
$('#quxian').combobox('clear'); //清除原有项目
$('#shi').combobox('reload','/Home/GetCity?parentid='+region.id);
$('#quxian').combobox('reload','/Home/GetCounty');//清理原有显示内容
}}"> </td>
<td>
<input id="shi" class="easyui-combobox" style="width:100px"
data-options="{
url:'/Home/GetCity',
valueField:'id',
textField:'text',
onSelect:function(region){
$('#quxian').combobox('clear'); //清除原有项目
$('#quxian').combobox('reload','/Home/GetCounty?parentid='+region.id);
}
}">
</td>
<td>
<input id="quxian" class="easyui-combobox" style="width:100px"
data-options="{
url:'/Home/GetCounty',
valueField:'id',
textField:'text'
}">
</td>
</tr>
</table>

3、后台(手动写的数据源,到时候可以换成自己的)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace SelectDemo.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/ /// <summary>
/// 获取省份
/// </summary>
/// <returns></returns>
public string GetProvince()
{
string json = "[{\"id\":1,\"text\":\"山东\"},{\"id\":2,\"text\":\"山西\"},{\"id\":3,\"text\":\"河北\"},{\"id\":4,\"text\":\"河南\"},{\"id\":5,\"text\":\"江苏\"}]"; return json;
} /// <summary>
/// 获取城市
/// </summary>
/// <param name="parentid"></param>
/// <returns></returns>
public string GetCity(string parentid)
{
string json = "[]";
if (parentid == "") //山东
json = "[{\"id\":1,\"text\":\"青岛\"},{\"id\":2,\"text\":\"菏泽\"},{\"id\":3,\"text\":\"济南\"},{\"id\":4,\"text\":\"潍坊\"},{\"id\":5,\"text\":\"济宁\"}]";
if (parentid == "") //山西
json = "[{\"id\":6,\"text\":\"太原\"},{\"id\":7,\"text\":\"大同\"}]";
if (parentid == "") //河北
json = "[{\"id\":8,\"text\":\"石家庄\"},{\"id\":9,\"text\":\"秦皇岛\"}]";
if (parentid == "") //河南
json = "[{\"id\":10,\"text\":\"郑州\"},{\"id\":11,\"text\":\"驻马店\"}]";
if (parentid == "") //江苏
json = "[{\"id\":12,\"text\":\"南京\"},{\"id\":13,\"text\":\"苏州\"}]";
return json;
} /// <summary>
/// 获取区县
/// </summary>
/// <param name="parentid"></param>
/// <returns></returns>
public string GetCounty(string parentid)
{
string json = "[]";
if (parentid == "") //青岛
json = "[{\"id\":1,\"text\":\"市南区\"},{\"id\":2,\"text\":\"市北区\"},{\"id\":3,\"text\":\"崂山区\"},{\"id\":4,\"text\":\"四方区\"},{\"id\":5,\"text\":\"李沧区\"}]";
if (parentid == "") //菏泽
json = "[{\"id\":6,\"text\":\"巨野县\"},{\"id\":7,\"text\":\"郓城县\"}]";
if (parentid == "") //济南
json = "[{\"id\":8,\"text\":\"历城区\"},{\"id\":9,\"text\":\"长清区\"}]";
if (parentid == "") //潍坊
json = "[{\"id\":10,\"text\":\"潍城区\"},{\"id\":11,\"text\":\"高密市\"}]";
if (parentid == "") //济宁
json = "[{\"id\":12,\"text\":\"微山县\"},{\"id\":13,\"text\":\"嘉祥县\"}]";
if (parentid == "") //太原
json = "[{\"id\":14,\"text\":\"迎泽区\"},{\"id\":15,\"text\":\"晋源区\"}]";
if (parentid == "") //大同
json = "[{\"id\":16,\"text\":\"平城区\"},{\"id\":17,\"text\":\"云冈区\"}]";
if (parentid == "") //石家庄
json = "[{\"id\":18,\"text\":\"新华区\"},{\"id\":19,\"text\":\"辛集市\"}]";
return json;
}
public ActionResult Index()
{
return View();
}
}
}

4、DEMO(另:demo附上不定行生成多个级联检索下拉选择框)

  SelectDemo

作者:小路 QQ:2490024434 
出处:http://www.cnblogs.com/lengzhan/
本文版权归【冷战】和博客园所有,欢迎转载收藏,未经作者同意须保留此段声明,否则保留追究法律责任的权利。

combobox级联检索下拉选择框的更多相关文章

  1. java、easyui-combotree树形下拉选择框

    最近一直在研究这个树形的下拉选择框,感觉非常的有用,现在整理下来供大家使用: 首先数据库的表架构设计和三级菜单联动的表结构是一样,(父子关系) 1.下面我们用hibernate建一下对应的额实体类: ...

  2. FancySelect – 更好用的 jQuery 下拉选择框插件

    FancySelect 这款插件是 Web 开发中下拉框功能的一个更好的选择.FancySelect 使用方便,只要绑定页面上的任何 Select 元素,并调用就 .fancySelect() 就可以 ...

  3. HTML、CSS小知识--兼容IE的下拉选择框select

    HTML <div class="s_h_ie"> <select id="Select1" disabled="disabled& ...

  4. Bootstrap系列 -- 15. 下拉选择框select

    Bootstrap框架中的下拉选择框使用和原始的一致,多行选择设置multiple属性的值为multiple.Bootstrap框架会为这些元素提供统一的样式风格 <form role=&quo ...

  5. CSS自定义select下拉选择框(不用其他标签模拟)

    今天群里有人问到怎么自定义select下拉选择框的样式,于是群里就展开了激烈的讨论,刚开始一直就是考虑怎样使用纯CSS实现,把浏览器默认的样式覆盖掉,但最后均因兼容问题处理不好而失败告终,最后的解决方 ...

  6. 基于jQuery美化联动下拉选择框

    今天给大家介绍一款基于jQuery美化联动下拉选择框.这款下下拉选择框js里自带了全国所有城市的数数库.下拉选择框适用浏览器:IE8.360.FireFox.Chrome.Safari.Opera.傲 ...

  7. ul+jquery自定义下拉选择框

    <!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. 背水一战 Windows 10 (105) - 通知(Toast): 带按钮的 toast, 带输入的 toast(文本输入框,下拉选择框)

    [源码下载] 背水一战 Windows 10 (105) - 通知(Toast): 带按钮的 toast, 带输入的 toast(文本输入框,下拉选择框) 作者:webabcd 介绍背水一战 Wind ...

  9. jQuery插件——下拉选择框

    其实,之前也写过jQuery插件,今天写的是一个模拟select选择的下拉插件. 既然是jQuery插件,那么必然是依赖jQuery的了. 老规矩,直接上代码吧! ;(function () { $. ...

随机推荐

  1. binary-tree-preorder-traversal——前序遍历

    Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tr ...

  2. HDU 1040 As Easy As A+B [补]

    今天去老校区找她,不想带电脑了,所以没时间A题了 /*******************************************************************/ As Ea ...

  3. 用JAVA编写浏览器内核之实现javascript的document对象与内置方法

    原创文章.转载请注明. 阅读本文之前,您须要对浏览器怎样载入javascript有一定了解. 当然,对java与javascript本身也须要了解. 本文首先介绍浏览器载入并执行javascript的 ...

  4. Python——类的高级主题

    介绍关于类的一些高级主题,这些是可选的,在Python应用程序中,不会常常遇到. =========================================================== ...

  5. 多媒体开发之---h264 取流解码分析

    1. nalu_unit_type = *((unsigned char *)pEmptyBuf->bufVirtAddr+4); nalu_unit_type = nalu_unit_type ...

  6. HDU 5188 背包

    有N道题.要求得到最少W分 给出N道题的:每道题用时T.分数V,应在且必须在L时刻提交才干得分 问得到W分所用的最少的时间 以L-T排序,然后做01背包就可以 #include "stdio ...

  7. exists用在linq上

    SQL里面,有时候会用到exists或者not exists. select * from yb t1 where not exists(select 1 from yb t2 where trunc ...

  8. DELPHI中的消息处理机制(三种消息处理方法的比较,如何截断消息)

    DELPHI中的消息处理机制 Delphi是Borland公司提供的一种全新的WINDOWS编程开发工具.由于它采用了具有弹性的和可重用的面向对象Pascal(object-orientedpasca ...

  9. java map 装入list

    需要生成多组数据的时候,应将map时候放入循环,否则循环出来会一直覆盖之前的,只能保存一条数据. 具体如下: if (rs.next()) { do { Map<String, String&g ...

  10. python 将屏幕输出定向到变量中

    #!/usr/bin/python # -*- coding: utf-8 -*- import sys import subprocess as sp def main(): cmd = 'syst ...