大家看看有什么问题,我在删除之前的input结点时,不能全部删除
<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>
?
<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>
?
1 楼
465886163
2010-08-26
<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");
var resultstr = "";
function setMultiple(val) {
var checkBox;
var checkboxDiv=document.getElementById("checkbox");
//checkboxDiv.style.display="none";
//alert(values[val].length);
input = checkboxDiv.getElementsByTagName("input");
alert(input.length);
for(var i = 0; i < input.length; i++){
//input[i].parentNode.removeChild(input[i]);
//checkboxDiv.removeChild(input[i]);
input[i].style.display="none";
}
for (var i = 0; i < values[val].length; i++) {
//alert(i);
//alert(checkboxDiv.getElementsByTagName('input').length);
resultstr=resultstr+"<input type='checkbox' name='cbox' value='"+values[val][i]+"'>"+values[val][i]
//checkboxDiv.style.display="block";
}
checkboxDiv.innerHTML=resultstr;
}
-->
</script>
2 楼
465886163
2010-08-26
晕死,那么麻烦
把checkboxDiv.innerHTML="";就可以了
真笨
把checkboxDiv.innerHTML="";就可以了
真笨