Esto perece que funciona??? No entiendo lo que te pasa...
Por cierto
Si obj es un checkbox luego puedes hacer
if (obj.checked) ... true si esta checkeado false si no lo esta
Quim
Código HTML:
Ver original<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/JavaScript"> var num89=0;
var num5=0;
function crear5(obj) {
if(num89%2 == 1) { /*paso 1*/
if (num5 <= 9) {
num5++;
fi5 = document.getElementById('fiel5'); /*paso 2*/
contenedor5 = document.createElement('div');
contenedor5.id = 'div'+num5;
fi5.appendChild(contenedor5);
ele5 = document.createElement('select');
ele5.className = 'impCol';
ele5.length = 4;
variable = new Option("Ser","0");
ele5.options[0] = variable;
variable = new Option("Ser1","1");
ele5.options[1] = variable;
variable = new Option("Ser2","2");
ele5.options[2] = variable;
variable = new Option("ser3","3");
ele5.options[3] = variable;
contenedor5.appendChild(ele5);
ele5 = document.createElement('input');
ele5.type = 'button';
ele5.value = 'Añadir';
ele5.name = 'div'+num5;
ele5.className ='impCol';
ele5.onclick = function () {num89=1;crear5(this);num89=2}
contenedor5.appendChild(ele5);
ele5 = document.createElement('input');
ele5.type = 'button';
ele5.value = 'Borrar';
ele5.name = 'div'+num5;
ele5.className ='impCol';
ele5.onclick = function () {borrar5(this.name)}
contenedor5.appendChild(ele5);
ele5 = document.createElement('textarea');
ele5.className = 'impCol';
ele5.cols =100;
ele5.rows = 4;
ele5.maxlength =2000;
contenedor5.appendChild(ele5);
}else{
alert('maximo de 10 servidores');
}
}else if(num89%2 == 0) { /*paso 3 donde se encuentra el error*/
var i ;
for (i=0;i<=num5;i++) {
fi5 = document.getElementById('fiel5');
fi5.removeChild(document.getElementById('div'+num5));
}
}
}
function borrar5(obj) {
num5--;
fi5 = document.getElementById('fiel5');
fi5.removeChild(document.getElementById(obj));
}
<input name="estilo" onclick="num89++;crear5(this)" type="checkbox" value="" />