bootstrap 下拉选择框select实现从服务器加载option
来源:互联网 发布:软件检测员待遇怎么样 编辑:程序博客网 时间:2024/04/29 18:08
昨天做了一个下拉菜单中的item从服务器加载,发现用在项目中并不合适,改用下拉选择框
前台代码:
<span style="font-family:Times New Roman;font-size:18px;"> <div class="form-group"> <label class="col-md-2 control-label" for="unitpart">设备分中心</label> <div class="col-md-10"> <select class="form-control" id="unitItem"></select> </div> </div></span>
<span style="font-family:Times New Roman;font-size:18px;"><span style="white-space:pre"></span>var unitItem = $("#unitItem").val();//取出传到后台的option的value值</span>
<span style="font-family:Times New Roman;font-size:18px;"> $("#unitItem").bind("click", function () { $.ajax({ url: "/control/showunit/", dataType: "json", success: function (data) { $.each(data, function (index, units) { $("#unitItem").append("<option value="+units.id+">" + units.unit + "</option>"); }); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert("error"); } }); });</span>另外注意一点,在取radio单选框中的值和文本值时的代码:
<span style="font-family:Times New Roman;font-size:18px;"> <div class="form-group"> <label class="col-md-2 control-label">设备摄像头类型</label> <div class="col-md-10" id="camera_type"> <label class="radio-inline"> <input type="radio" name="camera_type1" value="01" />xx1 </label> <label class="radio-inline"> <input type="radio" name="camera_type1" value="02" />xx2 </label> <label class="radio-inline"> <input type="radio" name="camera_type1" value="03" />xx3 </label> <label class="radio-inline"> <input type="radio" name="camera_type1" value="04" />xx4 </label> <label class="radio-inline"> <input type="radio" name="camera_type1" value="05" />xx5 </label> <label class="radio-inline"> <input type="radio" name="camera_type1" value="06" />xx6 </label> <label class="radio-inline"> <input type="radio" name="camera_type1" value="07" />xx7 </label> <label class="radio-inline"> <input type="radio" name="camera_type1" value="08" />xx8 </label> <label class="radio-inline"> <input type="radio" name="camera_type1" value="09" />xx9 </label> <label class="radio-inline"> <input type="radio" name="camera_type1" value="10" />xx10 </label> </div> </div> </span>
<span style="font-family:Times New Roman;font-size:18px;">var devscameratypeid = $("#camera_type input[name='camera_type1']:checked").val();//这里取出的是radio的value值var devscameratype = $("#camera_type input[name='camera_type1']:checked").parent().text();//这里取出的是type为radio的input标签的文本</span>
0 0
- bootstrap 下拉选择框select实现从服务器加载option
- 用bootstrap做下拉菜单,并使用jQuery实现从服务器加载下拉菜单的item。
- 通过ajax动态加载select控件【下拉框】的option
- Bootstrap-select多选下拉框实现
- Bootstrap-select多选下拉框实现
- 下拉框 select option 从数据字典中取值
- 【BootStrap】关于Select下拉框选择触发事件以及扩展
- js实现select下拉框选择
- bootstrap-select动态组装下拉选项(option)
- jquery实现动态加载select下拉框
- select选择下拉框
- Bootstrap-select搜索下拉框
- jquery ul>li模拟select>option下拉选择
- Bootstrap-Table实现从服务器加载数据进行显示
- Bootstrap-Table实现从服务器加载数据进行显示
- Bootstrap-Table实现从服务器加载数据进行显示
- Select下拉列表框(添加、删除option)
- Select下拉列表框(添加、删除option)
- JSP页面显示当前时间的后3天
- makefile书写入门
- 正向反向代理的理解
- [Leetcode]264. Ugly Number II
- 改善java程序之字符串
- bootstrap 下拉选择框select实现从服务器加载option
- ubuntu环境下如何解决svn提交出现can't check path '/home/...'
- 解决telnet: connect to address 127.0.0.1: Connection refused的错误信息(2)
- Effetive Objective - C 1.Objective 9
- Ubuntu系统挂载新硬盘方法
- 【使用工具和软件汇总】
- Struts2向action传对象数组
- Swift:Command failed due to signal: Segmentation fault: 11
- 编译AT91SAM9G25的linux步骤及出现的问题