recorrer tabla con jquery para insertar registros
Publicado por giuli (11 intervenciones) el 05/08/2016 19:03:18
hola amigos tengo una tabla html:
tengo el nombre y apellido de un alumno, y en un campo hidden el id. Pero tengo 5 radiobuttons donde, de acuerdo a la hora de llegada es el valor de la inasistencia, debo chequear en cada registro como esta marcado el alumno.
entonces intento usar el foreach:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<form action="" method="post" id="listado">
<section id="seccion">
<table width="100%" id="listaalumnos">
<tr>
<td width="25%" id="titulocolumna">Nombre</td>
<td width="25%" id="titulocolumna">Apellido</td>
<td width="10%" id="titulocolumna">Entera</td>
<td width="10%"id="titulocolumna">LT 1/4</td>
<td width="10%"id="titulocolumna">LT 1/2</td>
<td width="10%"id="titulocolumna">RA 1/4</td>
<td width="10%"id="titulocolumna">RA 1/2</td>
</tr>
<?php
if (isset($rsalumnos) && $rsalumnos!=null){
$total=count($rsalumnos);
$i=0;
foreach($rsalumnos as $alumno){$i++; ?><tr class="fila">
<div id="$i"><input type="hidden" size="0%" name="idalu"value="<?php echo $alumno['idalumno'];?>"/>
<td> <?php echo $alumno['nombre'];?></td>
<td> <?php echo $alumno['apellido']; ?></td>
<td> <input type="radio" value="1" name="<?php echo $i;?>" id="i1" /></td>
<td> <input type="radio" value="0.25" name="<?php echo $i;?>" id="i2" /></td>
<td> <input type="radio" value="0.5" name="<?php echo $i;?>" id="i3"/></td>
<td> <input type="radio" value="0.25" name="<?php echo $i;?>" id="i4"/></td>
<td> <input type="radio" value="0.5" name="<?php echo $i;?>" id="i5"/></td>
</tr>
<?php }}?>
</div>
</table>
</section>
<input type="submit" name="Actualizar"/>
</form>
tengo el nombre y apellido de un alumno, y en un campo hidden el id. Pero tengo 5 radiobuttons donde, de acuerdo a la hora de llegada es el valor de la inasistencia, debo chequear en cada registro como esta marcado el alumno.
entonces intento usar el foreach:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$("#Actualizar").click(function ()
{
$("#tabla tbody tr").each(function (index)
{
var idalu,tf;
$(this).children("td").each(function (index2)
{
switch (index2)
{
case 0: idalu = $(this).text();
break;
case 1: tf = $(this).val();
break;
}
$(this).css("background-color", "#ECF8E0");
})
$.ajax({
url: "consultaInasistencias.php?tf=tf",
type; 'post',
data: $("#listado").serialize(),
success: function(result){
$("#div1").html(result);
}});
})
})
});
Valora esta pregunta


0