How to have the value of a checkbox with javascript

0

I have a query or query as you like to tell, and in the query that I do to the table would be something like this:

$d151="select * from temporal where ncuenta>'399' and LENGTH(ncuenta)>3";
$db1=$dbh->prepare($d151);
$db1->execute();

the query works wonderfully without any complaints the fields of the table are

id int(11) NOT NULL AUTO_INCREMENT,
ncuenta varchar (100) COLLATE utf8_spanish_ci,
dcuenta varchar(100) COLLATE utf8_spanish_ci,
d151 TINYINT(1) COLLATE utf8_spanish_ci,

there is still everything going well.

<table>
<thead>
<tr>
<th>N°cuenta</th>
<th>Descripción</th>
<th>Agrega o Elimina</th>
</tr>
</thead>
<tbody>
<?php while ($ver=$db1->fetch(PDO::FETCH_ASSOC)){?>
<tr>
<td><?php echo $ver['ncuenta'];?></td>
<td><?php echo $ver['dcuenta'];?></td>
<td><input type="checkbox"id="agrega" onChange="agrega(<?php echo $ver['id'];?>);"
<?php if($ver['d151']==1){echo "checked='checked'";};?>>AGREGAR A CUENTAS</td>
</tr>
<?php };?>
</tbody>
</table>
<br>

Ok this is where the mule where I shoot Juan, when I say in the script what is the value of the check I get that is true but when I click to not check or remove the check I always get the value to true

    
asked by Oscar Melendez 14.06.2018 в 00:40
source

1 answer

0

in the end you can solve the dilemma differently with all the previous code I only change this part
<td> <?php if($ver['d151']==1){ $a="0||".$ver['id'];?> <button class="btn btn-success glyphicon glyphicon-ok"onclick="agrega1('<?php echo $a;?>');"></button> CUENTA AGREGADA <?php }else{$b="1||".$ver['id'];?> <button class="btn btn-danger glyphicon glyphicon-pencil"onclick="agrega1('<?php echo $b;?>');"></button> AGREGAR CUENTA<?php };?> </td>
and so I have the data that I need if it is zero then it is an account that is unmarked and if it is one it is an account that is set. I put the answer because maybe the idea can work for other people.

    
answered by 18.06.2018 / 18:00
source