$.ajax({
type: 'post',
url: "helper/ajax_search.php",
data: {models: decodeURIComponent(brands)},
dataType: 'json',
success: function(data) {
$('select.multiselect').empty();

$('select.multiselect').append(
$('<option></option>')
.text('alle')
.val('alle')
); $.each(data, function(index, html) {
$('select.multiselect').append(
$('<option></option>')
.text(html.name)
.val(html.name)
);
}); $('.multiselect').multiselect('rebuild')
},
error: function(error) {
console.log("Error:");
console.log(error);
}
});

<extend name="Public/base" />
<block name='style'>
<style type="text/css">
.sctext{ width:700px; height: 300px;}
</style>
</block>
<block name="body">
<div class="main-title cf">
<h2>渠道授权页面</h2>
</div>
<br/>

<!-- 表单 -->
<form id="form" action="{:U('/Admin/System/User/userChannelAuth')}" method="post" class="form-horizontal">
<input id="user_id" name="user_id" type="hidden" value="{$_GET['id']}">
<input id="user_name" name="user_name" type="hidden" value="{$_GET['name']}">
<div class="form-item">
<label class="item-label">平台类型<span class="check-tips">(请勾选平台类型)</span></label>
<div>
<select id="platform_type" name="platform_type[]" multiple="multiple">
<volist name="platform_type" id="vo">
<in name="vo.type_id" value="$platform_type_id">
<option value="{$vo.type_id}" class="row-select" selected="selected">{$vo.type_name}</option>
<else/>
<option value="{$vo.type_id}" class="row-select" >{$vo.type_name}</option>
</in>
</volist>
</select>
</div>
</div>
<br/>
<div class="form-item">
<label class="item-label">渠道<span class="check-tips">(请勾选渠道)</span></label>
<div>
<select id="channel" name="channel[]" multiple="multiple">
<volist name="ChannelInfo_data" id="vo">
<in name="vo.id" value="$channel_id">
<option value="{$vo.id}" class="row-select" selected="selected">{$vo.cn_name}</option>
<else/>
<option value="{$vo.id}" class="row-select" >{$vo.cn_name}</option>
</in>
</volist>
</select>
</div>
</div>
<br/>
<div class="form-item">
<label class="item-label">授权用户:{$_GET["name"]}<span class="check-tips"></span></label>

</div>
<br/>
<div class="form-item">
<button type="submit" class="btns submit-btn ajax-post" target-form="form-horizontal">授 权</button>
</div>
</form>
</block>

<block name="script">
<script type="text/javascript" charset="utf-8">
//导航高亮
highlight_subnav('{:U('/Admin/System/User/index')}');

highlight_subnav('{:U('saveServer')}');
Think.setValue('lua','{:I('lua')}');
$('#platform_type').multiselect(
{
enableFiltering: true,
nonSelectedText:'请选择平台类型',
filterPlaceholder:'搜索',
nSelectedText:'项被选中',
includeSelectAllOption:true,
selectAllText:'全选/取消全选',
allSelectedText:'已选中所有平台类型',
maxHeight:300
});
$('#channel').multiselect(
{
enableFiltering: true,
nonSelectedText:'请选择渠道',
filterPlaceholder:'搜索',
nSelectedText:'项被选中',
includeSelectAllOption:true,
selectAllText:'全选/取消全选',
allSelectedText:'已选中所有渠道',
maxHeight:300
});

$("#platform_type").bind("click",function(){

$("#channel option[value]").remove();
});
$("#platform_type").bind("change",function(){

var platform_type_ids=$("#platform_type").val();//获取所有的平台类型

if(platform_type_ids!=null){
var ulr='{:U('/Admin/System/User/getChannel')}';
$.ajax({
type:"GET",
url:ulr,
data:{ids:platform_type_ids},
dataType:"json",
success:function(data){
$("#channel option[value]").remove();

$(data).each(function(k,v){
$('#channel').append(
//selected="selected"
$('<option ></option>').text(v["cn_name"]).val(v["id"])
);
});
$('#channel').multiselect('rebuild');
$("#channel").multiselect( 'refresh' );
}
});
}else{

$('#channel').multiselect('destroy');
$('#channel').empty();
$('#channel').multiselect({
enableCaseInsensitiveFiltering : true,
nonSelectedText:'请选择渠道',
maxHeight:300

});

}

});

</script>
</block>

Bootstrap Multiselect 设置 option的更多相关文章

  1. web 前端常用组件【03】Bootstrap Multiselect

    实际的项目网站中或多或少的或用到多选框,我选用的一款是 Bootstrap Multiselect. 官方文档:http://www.kuitao8.com/demo/20140224/1/boots ...

  2. JS组件系列——两种bootstrap multiselect组件大比拼

    前言:今天继续来看看bootstrap的另一个组件:multiselect.记得在项目开始之前,博主项目组几个同事就使用哪些js组件展开过讨论,其中就说到了select组件,由于项目的整体风格使用的b ...

  3. bootstrap multiselect两大组件

    组件说明以及API 1.第一个组件——multiple-select.这个组件风格简单.文档全.功能强大.但是觉得它选中的效果不太好.关于它的效果展示,我们放在后面. 2.第二个组件——bootstr ...

  4. Bootstrap Multiselect插件使用步骤以及常见参数配置介绍

    Multiselect是基于jQuery插件的,它可以以下拉列表的形式为用户提供选择内容,能进行单选或者多选.它应用的主要步骤如下: 一,引入需要的相关js和css文件 既然是Bootstrap插件, ...

  5. Bootstrap Multiselect

    Getting Started Link the Required Files First, the jQuery library needs to be included. Then Twitter ...

  6. 使用BootStrap框架设置全局CSS样式

    一.排版 标题 HTML 中的所有标题标签,<h1> 到 <h6> 均可使用.另外,还提供了 .h1 到 .h6 类,为的是给内联(inline)属性的文本赋予标题的样式. & ...

  7. easyui-combobox 设置option内容不换行

    使用easyui 1.4.4 1 2 3 4 5 6 7 8 <select id="hotalid" class="easyui-combobox" d ...

  8. Django实战(5):引入bootstrap,设置静态资源

    之前生成了Product类的scaffold,但是如同rails的开发者David所讲的那样,scaffold几乎没什么用.所以按照<Agile Web Development with Rai ...

  9. js 动态设置 option 的selected 选项

    思路:通过for循环判断每个选项,一旦满足条件则设置其selected属性为true即可,关键代码: var obj = document.getElementById(select_id); for ...

随机推荐

  1. STL 源代码剖析 算法 stl_algo.h -- next_permutation

    本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie next_permutation ----------------------------- ...

  2. 在页面左右一个悬浮div兼容IE6 IE7 8 9 Firefox chrome

    在页面左右一个悬浮div兼容IE6 IE7 8 9 Firefox chrome #identifier-pannel { bottom: 345px; margin-left: 512px; pos ...

  3. Node.js aitaotu图片批量下载Node.js爬虫1.00版

    即使是https网页,解析的方式也不是一致的,需要多试试. 代码: //====================================================== // aitaot ...

  4. .Net Framemwork 之 值类型和引用类型的存储

    C#把数据类型分为两种:值类型 和 引用类型.值类型存储在堆栈中,而引用类型存储在托管堆上. 一.值类型和引用类型变量的存储 首先,变量是存储信息的基本单元,而对于计算机内部来说,变量就相当于一块内存 ...

  5. vb.net小试三层架构

    在对三层架构有了初步了解后,用vb.net做了一个小的程序,真的很小,仅仅是为了体现一下三层之间机制.下面是我设计的操作界面: 还有程序集和类的分布情况, 接下来是数据的设计,数据库用到的是SQL S ...

  6. Coursera-Algotithms学习

    Week1 Job Interview Question Social network connectivity. Given a social network containing N member ...

  7. array_intersect_assoc用法详解

    最近在做考试系统,想到这个数组函数,用法如下: <?php $a1=array('a','b','d','c','d','b','c','a'); $a2=array('b','d','d',' ...

  8. Xshell5 破解

    Xshell5激活码 Xshell5激活方式Xshell5破解版 Xshell是一个用于MS Windows平台的强大的SSH,TELNET,和RLOGIN终端仿真软件.它使得用户能轻松和安全地从Wi ...

  9. 在Docker中执行web应用

    启动一个简单的web 应用 使用社区提供的模板,启动一个简单的web应用,熟悉下各种Docker命令的使用: # docker run -d -P training/webapp python app ...

  10. CentOS7 升级到7.4

    2 升级CentOS7.4 自己电脑上的系统还是CentOS7.2,服务器是CentOS7.3, 打算统统升级到最新版 升级前查看 > lsb_release -a LSB Version: : ...