Holas a tod@s,
Como puedo obtener los id's de los elementos que están incluidos dentro de una tabla? Me explico: en el script:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body class="clasebody">
<table width="100%" height="100%" border="1" cellspacing="0" cellpadding="0">
<table border="0" cellspacing="0" cellpadding="0">
<form id="forma1" name="forma1" method="post">
<table id="formulario" border="0" cellspacing="4" cellpadding="0">
<tr>
<td class="clasetd">Grupos de Columnas:
</td>
<td>
<input type="text" id="grupos" name="grupos" value="" class="claseinput" style="width:30px;">
</td>
<td class="clasetd">Nro. Columnas:
</td>
<td>
<input type="text" id="cols" name="cols" value="" class="claseinput" style="width:30px;" onChange="javascript: crearFilas();">
</td>
</tr>
</table>
<!-- En esta parte (<table id="reporte"... >) debe ir lo que se ha creado mediante document.createElemet() -->
<table id="reporte" name="reporte">
</table>
<table>
<tr>
<input type="button" value="Grabar" id="graba" name="accion" onClick="fDatos('reporte','grabar');" style="background-color: #738EB5; height: 18; font-size: 8 pt; font-weight: bold; color: ffffff; border-style: solid; border-width: 1">
</tr>
</table>
</form>
</table>
</table>
</body>
</html>
Dentro de
<table id="reporte" name="reporte"> va incluido una serie de elementos como inputs, selects, textareas, etc. creados con document.createElement(); algo como
Código PHP:
.
.
.
i = 0;
k = 1;
largo = ((140*cols)+(3*cols));
for (i=0;i<grups;i++) {
idnameg="grp"+k+"_0";
nuevoTD = document.createElement("td");
nuevoTD.setAttribute("colspan", cols);
tbl.appendChild(nuevoTD);
input = document.createElement("input");
input.setAttribute("type", "text");
input.setAttribute("id", idnameg);
input.setAttribute("name", idnameg);
input.setAttribute("value", "Titulo Grupo "+k);
input.setAttribute("class", "claseinput");
estilo = "text-align:center; width:"+largo+"px; color:blue;";
input.setAttribute("style", estilo);
input.setAttribute("onChange", "verificaInput('"+idnameg+"');");
nuevoTD.appendChild(input);
tbl.appendChild(nuevoTD);
k++;
}
tbl.appendChild(tr);
.
.
.
Debido a que la cantidad de elementos es variable y los id's creados igualmente son dinámicos o variables, como se quiera, en el momento de enviar los datos al servidor se necesita armar un queryString con los respectivos datos que van en esta parte el form
Entonces, como puedo obtener los id's de los elementos de la tabla reporte contenida en la forma forma1?
Gracias de antemano por su ayuda
Un Cordial Saludo