怎么做一个当复选框被选中时,复选框的值出现在一个文本框里
1个回答
展开全部
用javaScript啊
<script type="text/javascript">
function checkbox() {
var str = document.getElementsByName("box");
var objarray = str.length;
var chestr;
var chestrName;
for (i = 0; i < objarray; i++) {
if (str[i].checked == true)
{
chestr += str[i].value + ",";
if (str[i].id != null) {
chestrName += str[i].id + " ";
}
}
}
document.all.txt.value = chestrName;
}
</script>
<div>
<input type="text" name="txt" value=" " style="height:35px;width:430px"/>
<input type="checkbox" name="box" id="111" value="11111" onclick="checkbox()"/>
</div>
<script type="text/javascript">
function checkbox() {
var str = document.getElementsByName("box");
var objarray = str.length;
var chestr;
var chestrName;
for (i = 0; i < objarray; i++) {
if (str[i].checked == true)
{
chestr += str[i].value + ",";
if (str[i].id != null) {
chestrName += str[i].id + " ";
}
}
}
document.all.txt.value = chestrName;
}
</script>
<div>
<input type="text" name="txt" value=" " style="height:35px;width:430px"/>
<input type="checkbox" name="box" id="111" value="11111" onclick="checkbox()"/>
</div>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询