I have the following code:
var fila='<tr class="selected" id="fila'+cont+'" onclick="seleccionar(this.id);"><td>'+cont+'</td><td>'+$('input[name="fk_animalito"]').val();+'</td><td>'+$($('input[name^="fk_hora_sorteo"]')[0]).val()+'</td><td>'+$('input[name="monto"]').val();+'</td></tr>';
The input type="text"
captures them well and they show me in the table perfectly, the problem is: input type='checkbox' name='fk_hora_sorteo[]'
that as I am passing it as array I do not capture the value to show it in the table; I have tried like this, but it does not work for me:
$($('input[name^="fk_hora_sorteo"]')[0]).val()
The form:
<form id="idFormulario" action="" method="POST">
<!-- section -->
<section>
<div class="row">
<div class="container">
<?php
$consulta = $DB_con->query("SELECT * FROM hora_sorteo ORDER BY id");
if($consulta->rowCount() > 0) {
while ($linea = $consulta->fetch(PDO::FETCH_ASSOC)) {
echo "<div class='col s6 m2'>";
echo "<input type='checkbox' name='fk_hora_sorteo[]' id='chk1{$linea['id']}' value='{$linea['id']}'>";
echo "<label class='black-text' for='chk1{$linea['id']}'>{$linea['hora_sorteo']}</label>";
echo "</div>";
}
}
else
echo "<div class='col s12 card-panel yellow darken-2 center'>
<h5 class='black-text text-darken-2 center CONDENSED LIGHT5'>¡
Advertencia: No se ha encontrado ningún registro !</h5>
</div>";
?>
</div>
</div>
</section>
<section>
<div class="row">
<?php
$consulta = $DB_con->query("SELECT * FROM animalitos ORDER BY id");
if($consulta->rowCount() > 0) {
$i=1;
while ($linea = $consulta->fetch(PDO::FETCH_ASSOC)) {
?>
<div class="col s1 m1">
<div class="chip">
<img src="../galerias_animalitos/<?= $linea['portada']?>" alt="imagen animalitos"/>
<?php echo $linea['numero']; ?> <?php echo $linea['nombre']; ?>
</div>
</div>
<?php
$i++;
}
}
else
echo "<div class='col s12 card-panel yellow darken-2 center'>
<h5 class='black-text text-darken-2 center CONDENSED LIGHT5'>¡
Advertencia: No se ha encontrado ningún registro !</h5>
</div>";
?>
</div>
</section>
<!-- fin section -->
<div class="row">
<div class="col s12 m5">
<div class="input-field col s12 m4">
<input type="text" name="fk_animalito" autocomplete="off" required/>
<label for="descripcion" class="black-text ">Numero Animalito:</label>
</div>
<div class="input-field col s12 m4">
<input id="bt_add" type="text" name="monto" autocomplete="off" required/>
<label for="descripcion" class="black-text ">Monto:</label>
</div>
<br>
<br>
<br>
<br>
<button class="btn waves-effect blue darken-4 btn-small" type="submit" name="guardar">Generar Jugada</button>
<button id="bt_del" class="btn waves-effect red btn-medium">Eliminar</button>
<button id="bt_delall" class="btn waves-effect red btn-medium">Eliminar Todo</button>
<div class="col center s12 m12">
<h4 class="left-align black-text">Serial: Total:</h4>
</div>
</div>
</form>
<div class="col s12 m7">
<div style=' overflow: auto; height: 250px;'>
<table id="tabla_ventas" class='bordered responsive-table centered'>
<thead>
<tr>
<th data-field='Nº'>N°</th>
<th data-field='Nº'>ANIMALITO</th>
<th data-field='Código'>SORTEO</th>
<th data-field='Código'>MONTO</th>
</tr>
</thead>
</table>
</div>
</div>
Annex the image: