当前位置: 代码迷 >> Web前端 >> CheckBox怎么多选
  详细解决方案

CheckBox怎么多选

热度:86   发布时间:2012-11-05 09:35:12.0
CheckBox如何多选
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function test()
{
var value=""; //document.getElementsByName("value1").value;
for(i=0;i<4;i++)
{
if(document.getElementsByName("Status")[i].checked==true)
{
  if(value==""){
  value=value+document.getElementsByName("Status")[i].value;
  }
  else{
  value=value+","+document.getElementsByName("Status")[i].value;
}
}

}
alert(value);
document.all.value1.value = value;

}


</script>
</head>

<body>
<input name="Status" type="checkbox" value="1" onclick="test()"/>

<input name="Status" type="checkbox" value="2" onclick="test()"/>

<input name="Status" type="checkbox" value="3" onclick="test()"/>

<input name="Status" type="checkbox" value="4" onclick="test()"/>

<input type="text"  name="value1" value=""  size="50"/>

</body>
</html>
  相关解决方案