Código:
ahora la creacion dinamica de textsfunction agregarEvento(elemento, nombre_evento, funcion, captura){ // para IE
if (elemento.attachEvent){alert("iE"+elemento.attachEvent);
elemento.attachEvent('on' + nombre_evento,function(){ funcion;} );
return true;
}else // para navegadores respetan Estándares DOM(Firefox,safari)
if (elemento.addEventListener){alert("otro"+elemento.addEventListener);
elemento.addEventListener(nombre_evento,function(){funcion},captura);
return true;
}else
{
alert("otro"+elemento.addEventListener);
alert("iE"+elemento.attachEvent)
return false;
}
}
Código:
la porcion de codigo en phpfunction agregarFilaGral(vec)
{
tabla= document.getElementById(vec[0]);
// crea TR
row = document.createElement('tr');
//row.className=""+clase+"";
ID=contIDG;
vecG.push(ID);
row.id =""+vec[0]+ID+"";
for(i=1;i<vec.length;i++)
{
if(i==(vec.length-1))
{
ch=document.createElement('input');
ch.type='checkbox';
ch.id=""+vec[i]+ID+"";
td1 = document.createElement("td");
td1.setAttribute("align","center");
td1.appendChild(ch);
row.appendChild(td1);
}
else
{
texto = document.createElement('input');
texto.type='text';
texto.id=""+vec[i][0]+ID+"";
for(j=1;j<vec[i].length;j++)
{
if(vec[i][j][0]=="width")
{
texto.style.width=vec[i][j][1];
}
else
{
//texto.setAttribute("on"+vec[i][j][0],vec[i][j][1]);
agregarEvento(texto.id,vec[i][j][0],vec[i][j][1],false);
}
}
//texto.setAttribute("onchange","verificar_carateresEsp(this.value)");
td1 = document.createElement("td");
td1.setAttribute("align","center");
td1.appendChild(texto);
row.appendChild(td1);
alert(td1.innerHTML);
}
}
tabla.appendChild(row);
contIDG++;
}
Código PHP:
echo "<div><table id='tablaE'>";
echo "<tbody id='tablaRE'>";
echo "<script>var v4=new Array('tablaRE',new Array('resp',new Array('change','verificar_carateresEsp(this.value)')),new Array('color',new Array('width','50px'),new Array('click','startColorPicker(this)'),new Array('keyup','maskedHex(this)')),'chRE');</script>";
echo "<tr><td colspan='3'><div align='right'><img src='imagen/botones/fondodeA+.jpg' alt='agregar' onClick=\"agregarFilaGral(v4);\"/><img src='imagen/botones/elim.gif' alt='Eliminar Fila' onClick=\"eliminarFilaGral('tablaRE','chRE');\"/><img src='imagen/botones/undo.gif' alt='Restaurar' onClick=\"restaurarFilaGral(v4);\" /></div></td></tr>";
echo "<tr><td align='center'>Respuesta</td><td align='center'>color</td><td></td></tr>";

