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. uva 11488 - Hyper Prefix Sets(字典树)

    H Hyper Prefix Sets Prefix goodness of a set string is length of longest common prefix*number of str ...

  2. 《Deep Learning》全书已完稿_附全书电子版

    Deep Learning第一篇书籍最终问世了.站点链接: http://www.deeplearningbook.org/ Bengio大神的<Deep Learning>全书电子版在百 ...

  3. bzoj1601【Usaco2008 Oct】灌水

    1601: [Usaco2008 Oct]灌水 Time Limit: 5 Sec  Memory Limit: 162 MB Submit: 1589  Solved: 1035 [Submit][ ...

  4. python使用cx_oracle连接oracle数据库

    http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html---下载instantclient-basic-linux.x ...

  5. Devices下设备的进程显示为问号的问题

     adb shell getprop ro.debuggable      返回  ro.debuggable=0     说明这个机子的版本不是userdebug版本,是user版本     只有这 ...

  6. char* strcpy( char* dest, const char* src ), int binary_search(int *arr, int key, int n), 可能的实现

    #include <stdio.h> char* stringCopy( char* dest, const char* src ) { size_t i = 0; while (dest ...

  7. poj 1015 Jury Compromise(背包+方案输出)

    \(Jury Compromise\) \(solution:\) 这道题很有意思,它的状态设得很...奇怪.但是它的数据范围实在是太暴露了.虽然当时还是想了好久好久,出题人设了几个限制(首先要两个的 ...

  8. Handler有何作用?怎样使用?

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u012974916/article/details/24580405 一  Handler作用和概念 ...

  9. ssm使用velocity模板语言

    1.在pom.xml里添加velocity模板语言支持的依赖 <!-- velocity模板语言支持包 --> <dependency> <groupId>org. ...

  10. 推箱子 hdu1254

    推箱子 1  http://acm.hdu.edu.cn/showproblem.php?pid=1254 推箱子 2  http://acm.hzau.edu.cn/problem.php?id=1 ...