code=HTML]<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/HTML;charset=utf-8" />
<title>复选框</tITle><script type="text/JAVAscript">
<!--
var values = new Array();
values[0] = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9");
values[1] = new Array("a", "b", "c", "d", "e", "f", "g", "h");
function setMultiple(val) {
var checkBox;
var checkboxDiv=document.getElementById("checkbox");
//checkboxDiv.style.display="none";
//alert(values[val].length);
input = checkboxDiv.getElementsByTagName("input");
for(var i = 0; i < input.length; i++){
//input[i].parentNode.removeChild(input[i]);
checkboxDiv.removeChild(input[i]);
}
for (var i = 0; i < values[val].length; i++) {
//alert(i);
//alert(checkboxDiv.getElementsByTagName('input').length);
checkBox = document.createElement("input");
checkBox.type = "checkbox";
checkBox.name = "name";
checkboxDiv.appendChild(checkBox);
checkboxDiv.appendChild(document.createTextNode(values[val][i]));
//checkboxDiv.style.display="block";
}
}
-->
</script>
</head>
<body>
<div id="div_parent">
<select onchange="setMultiple(this.value);"><option value=0>--00--</option><option value=1>--11--</option></select>
</div>
<div id="checkbox"></div>
</body>
</HTML>
[/code]
大家帮忙看看源代码,有什么问题
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/HTML;charset=utf-8" />
<title>复选框</tITle><script type="text/JAVAscript">
<!--
var values = new Array();
values[0] = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9");
values[1] = new Array("a", "b", "c", "d", "e", "f", "g", "h");
function setMultiple(val) {
var checkBox;
var checkboxDiv=document.getElementById("checkbox");
//checkboxDiv.style.display="none";
//alert(values[val].length);
input = checkboxDiv.getElementsByTagName("input");
for(var i = 0; i < input.length; i++){
//input[i].parentNode.removeChild(input[i]);
checkboxDiv.removeChild(input[i]);
}
for (var i = 0; i < values[val].length; i++) {
//alert(i);
//alert(checkboxDiv.getElementsByTagName('input').length);
checkBox = document.createElement("input");
checkBox.type = "checkbox";
checkBox.name = "name";
checkboxDiv.appendChild(checkBox);
checkboxDiv.appendChild(document.createTextNode(values[val][i]));
//checkboxDiv.style.display="block";
}
}
-->
</script>
</head>
<body>
<div id="div_parent">
<select onchange="setMultiple(this.value);"><option value=0>--00--</option><option value=1>--11--</option></select>
</div>
<div id="checkbox"></div>
</body>
</HTML>
[/code]
大家帮忙看看源代码,有什么问题
var xxAryL = xxAry.length;
for(var i=xxAryL -1;i>=0 ;i--){
document.getElementById("aaa").removeChild(xxAry[i]);
}
----------------------------------------------------------------------------
var xxAry = document.getElementsByName("xx");
var xxAryL = xxAry.length;
for(var i=0;i<xxAryL ;i++){
document.getElementById("aaa").removeChild(xxAry[0]); //每次都移除第一个元素
}类似这样操作下 , 你懂的 呵呵
var xxAryL = xxAry.length;
for(var i=xxAryL -1;i>=0 ;i--){
document.getElementById("aaa").removeChild(xxAry[i]);
}
----------------------------------------------------------------------------
var xxAry = document.getElementsByName("xx");
var xxAryL = xxAry.length;
for(var i=0;i<xxAryL ;i++){
document.getElementById("aaa").removeChild(xxAry[0]); //每次都移除第一个元素
}类似这样操作下 , 你懂的 呵呵
var xxAryL = xxAry.length;
for(var i=xxAryL -1;i>=0 ;i--){
document.getElementById("aaa").removeChild(xxAry[i]);
}
----------------------------------------------------------------------------
var xxAry = document.getElementsByName("xx");
var xxAryL = xxAry.length;
for(var i=0;i<xxAryL ;i++){
document.getElementById("aaa").removeChild(xxAry[0]); //每次都移除第一个元素
}类似这样操作下 , 你懂的 呵呵