(转)JS 获取 checkbox 的显示值
<html>
<head>
</head>
<script>
function demo(){
var namevalue = document.getElementsByName("user");
for(var i=0;i<namevalue.length;i++){
var value1 = namevalue[i].nextSibling.nodeValue;
if(namevalue[i].checked){
alert(value1);
}
}
}
</script>
<body>
<input type="checkbox" id="accept" name="user" value="1"/>a
<input type="checkbox" id="accept1" name="user" value="2"/>b
<input type="checkbox" id="accept2" name="user" value="3"/>c
<input type="checkbox" id="accept3" name="user" value="4"/>d
<input type="checkbox" id="accept4" name="user" value="5"/>e
<input type="button" name="js_btn" value="提交" onclick="demo();">
</form>
</body>
</html>
原文:http://hi.baidu.com/python_php/blog/item/191c7afefc22d151d7887d6f.html