您现在的位置是:网站首页 > 脚本编程>
jquery实现全选并赋值给指定文本框
简介
今天做邮件群发,需要全选并赋值到文本框,本代码是由全选功能改编过来的。如有不妥之处请留言改正。
代码:
<script>
function uncheckAll()
{
var code_Values = document.getElementsByName('email');
var tem= d...
今天做邮件群发,需要全选并赋值到文本框,本代码是由全选功能改编过来的。如有不妥之处请留言改正。
代码:
<script>
function uncheckAll()
{
var code_Values = document.getElementsByName('email');
var tem= document.getElementById("to").value;
var bb=document.getElementById('to');
if(code_Values.length)
{
for(var i=0;i<code_Values.length;i++)
{
if(code_Values[i].checked)
{
code_Values[i].checked = false;
tem = tem.replace(code_Values[i].value+",","");
}
else
{
code_Values[i].checked = true;
tem += code_Values[i].value +",";
}
}
}
bb.value=tem;
}
</script>
<input id="to" type="text" class="input" size="60" name="to" value=""/>
<input type="button" class="btn" onclick="javascript:uncheckAll();" value="ȫѡ"/>
<label><input type="checkbox" value="1111" name="email"/> 111111</label>
<label><input type="checkbox" value="2222" name="email"/> 222222</label>
<label><input type="checkbox" value="3333" name="email"/> 333333</label>
效果图:
打赏本站,你说多少就多少

本文地址:https://www.qi522.com/view/70.html
来 源:千奇博客