点input框,弹出一个多选框checkbox,进行选择,每个以逗号隔开
2016-07-29 10:56
375 查看
点input框,弹出一个多选框,进行选择,每个以逗号隔开,如上图所示
1. <input id="taskPlanDay" name="taskPlanDay" type="text" style="width: 150px" class="inputxt" readonly="readonly"
datatype="*"
>
2.js片段
<script language="javascript">
$('#taskPlanDay').bind('focus', function() {
var offset = $(this).offset(), container = $('div.container');
container.css({top:offset.top+Number($(this).css('height').replace('px', '')), left:offset.left}).show(100);
});
$(document).bind('click', function(){
var targ;
if (event.target) targ = event.target
else if (event.srcElement) targ = event.srcElement
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
if (targ.id !='taskPlanDay' && !$(targ).parents('div.container').attr('class'))
$('div.container').hide(100);
});
$('#submit').bind('click', function(){
var vals = '', length;
$('div.frame input[type=checkbox]:checked').each(function(){
vals += ($(this).next().text() + ',');
});
if ((length = vals.length) > 0) vals = vals.substr(0, length -1);
$('#taskPlanDay').val(vals);
$('div.container').hide(100);
});
$('#close').bind('click', function(){
$('div.container').hide(100);
});
</script>
2.<div>代码块
<div class="container">
<div class="shadow">
<div class="frame">
<div><input type="checkbox" id="location01"/><label for="location01">01</label></div>
<div><input type="checkbox" id="location02"/><label for="location02">02</label></div>
<div><input type="checkbox" id="location03"/><label for="location03">03</label></div>
<div><input type="checkbox" id="location04"/><label for="location04">04</label></div>
<div><input type="checkbox" id="location05"/><label for="location05">05</label></div>
<div><input type="checkbox" id="location06"/><label for="location06">06</label></div>
<div><input type="checkbox" id="location07"/><label for="location07">07</label></div>
<div><input type="checkbox" id="location08"/><label for="location08">08</label></div>
<div><input type="checkbox" id="location09"/><label for="location09">09</label></div>
<div><input type="checkbox" id="location10"/><label for="location10">10</label></div>
<div><input type="checkbox" id="location11"/><label for="location11">11</label></div>
<div><input type="checkbox" id="location12"/><label for="location12">12</label></div>
<div><input type="checkbox" id="location13"/><label for="location13">13</label></div>
<div><input type="checkbox" id="location14"/><label for="location14">14</label></div>
<div><input type="checkbox" id="location15"/><label for="location15">15</label></div>
<div><input type="checkbox" id="location16"/><label for="location16">16</label></div>
<div><input type="checkbox" id="location17"/><label for="location17">17</label></div>
<div><input type="checkbox" id="location18"/><label for="location18">18</label></div>
<div><input type="checkbox" id="location19"/><label for="location19">19</label></div>
<div><input type="checkbox" id="location20"/><label for="location20">20</label></div>
<div><input type="checkbox" id="location21"/><label for="location21">21</label></div>
<div><input type="checkbox" id="location22"/><label for="location22">22</label></div>
<div><input type="checkbox" id="location23"/><label for="location23">23</label></div>
<div><input type="checkbox" id="location24"/><label for="location24">24</label></div>
<div><input type="checkbox" id="location25"/><label for="location25">25</label></div>
<div><input type="checkbox" id="location26"/><label for="location26">26</label></div>
<div><input type="checkbox" id="location27"/><label for="location27">27</label></div>
<div><input type="checkbox" id="location28"/><label for="location28">28</label></div>
<div><input type="checkbox" id="location29"/><label for="location29">29</label></div>
<div><input type="checkbox" id="location30"/><label for="location30">30</label></div>
<div><input type="checkbox" id="location31"/><label for="location31">31</label></div>
<div class="foot" style="text-agiln:right" style="margin:0 8px"><a href="#" id="submit" margin-right:20px>确定</a><a href="#" id="close" margin-right:20px>取消</a></div>
</div>
</div>
</div>
3.css样式代码
<style type="text/css">
.container {position:absolute; display:none; padding-left:10px;}
.shadow {float:left;}
.frame {position:relative; background:#ffc; padding:6px; display:block;
-moz-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.6);
-webkit-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.6);
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.6);
overflow: hidden;
width:310px
}
.clear {clear:left;}
label,a {font-size:13px;color:#4f6b72;}
#language {font-size:13px;color:#4f6b72;border:1px solid #4f6b72;height:20px;}
div.frame div {margin-bottom:5px; float:left}
div.frame div.foot {margin-top:15px; text-agiln:right; margin-right:20px; float:right}
div.frame div.foot.a{margin-right:20px}
div.frame label {margin: 0 10px 0 5px;}
div.frame a:link,div.frame span a:visited {
text-decoration:none; margin:0 8px;
</style>
相关文章推荐
- 已知一个几乎有序的数组,几乎有序是指,如果把数组排好顺序的话,每个元素移动的距离可以不超过k,并且k相对于数组来说比较小。请选择一个合适的排序算法针对这个数据进行排序。 给定一个int数组A,同时给定
- js弹出一个新窗口进行选择并且返回这个页面的值-showModalDialog
- 点击一个图片弹出文件选择进行上传
- 将所有符合条件的结果拼接成一列并用逗号隔开的一个sql语句
- 选择一个JavaScript框架进行WEB开发[转]
- 用函数获得一个类型下所有的数据,并用逗号隔开,显示出来
- 如何在Excel里单击一个单元格弹出一个日期选择控件,选择日期值后返回给该单元格。
- 在TDBGrid中绘制一个多选框(CheckBox)
- 1.编写一个程序,这个程序把一个整数数组中的每个元素用逗号连接成一个字符串,例如,根据内容为[1][2][3]的数组形成内容
- 在一组checkbox中,只少选择一个,才可以提交
- 如何在Excel里单击一个单元格弹出一个日期选择控件,选择日期值后返回给该单元格。
- 选择每个订单的每种费用的数目,每行纪录为一个订单信息
- 包含CHECKBOX的DataGrid(一个属性获得所选择的项)
- 把所有符合条件的结果拼接成一列,用逗号隔开的一个sql语句。
- 将所有符合条件的结果拼接成一列并用逗号隔开的一个sql语句
- html鼠标选择一个区域,把该区域checkbox 都选中
- 一个弹出的树形选择菜单
- 一个弹出的树形选择菜单
- 一个简单自定义屏幕,并调用word和excel的样例程序 1000弹出选择按钮
- 一个应用策略模式(Strategy)的小实例----对TreeView功能菜单的功能选择模块进行解耦重构