如何取得checkbox选中的值
表:mytable和textbox1
checkbox列 user_id user_name
1 小华
2 小强
5 小白
... .... ...
如果1.3行选中,如何得到user_id的值并显示在文本框中.如本例文本框显示的是:1,5
------解决方案--------------------script language=JavaScript>
function init(){
var checkboxs = document.getElementsByName( 'check ');
for (var i = 0;i < checkboxs.length; i++){
document.getElementById( "文本框ID ").value=checkboxs[i].value;
}
}
</script>
</head>
<body onload=init()>
<input name=check type=checkbox value=1 checked>
<input name=check type=checkbox value=2 checked>
<input name=check type=checkbox value=3 checked>
<input name=check type=checkbox value=4 checked>
<input name=check type=checkbox value=5 checked>
------解决方案--------------------getParameterValue(String name) 返回的应该是叔祖,name填checkbox的name
------解决方案-------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
<script language= "javascript ">
function onload()
{
var arr=document.getElementsByTagName( "input ");
for (var i=0;i <arr.length ;i++ )
{
if (arr[i].type== "checkbox ")
{
arr[i].attachEvent( "onclick ",fangfa);
}
}
}
function fangfa()
{
document.forms[0].text.value+=event.srcElement.value;
}
</script>
</HEAD>
<BODY onload= "onload() ">
<form id= "a ">
<input type= "text " name= "text "/>
<input name=check type=checkbox value=1 >
<input name=check type=checkbox value=2 >
<input name=check type=checkbox value=3 >
<input name=check type=checkbox value=4 >
<input name=check type=checkbox value=5 >
</form>
</BODY>
</HTML>
------解决方案--------------------人家给你的是对的,自己想想问题出在哪里了吧
------解决方案--------------------你在生成checkbox的时候就把user_id的值放到checkbox的value里面去,然后用1楼的方法取出来就可以了
------解决方案--------------------<table style="width: 205px; height: 64px">
<tr>
<td>
checkbox</td>