I have a form with three select
, that I get certain data from the database and when generating them, a graph with the detail is displayed according to the select
selected of year from 2015 for example to 2017, and after of selecting the selected checkboxes appear by default. I did this with ( checked='checked'
), since the graphic should show me all the detail the first time the user enters the page.
My problem is that when I deactivate the checkbox
by hitting the button submit
, yes, it gives me the data I require, but the checkbox
is not deselected or the popcorn is not removed when refreshing the page.
I have searched everywhere without success, maybe my logic or what I am doing is wrong because I have not stayed.
I send the part of the code:
<div id="anio_mes" name="anio_mes" >
<td width="13%" tdwidth="9%"><strong>Anio y mes a deseleccionar:</strong></td>
<td width="100%">
<?php
$query_anio = "SELECT anio,mes
FROM [heba].[dbo].[t_rpu_facturacion]
where anio between '$anioini' and '$aniofin'
GROUP BY anio,mes
ORDER BY anio, mes";
$resulset_anio= consultarMSSQL($query_anio);
//$b=1;
while($row_anio= $resulset_anio->fetch()){
$anomes=trim($row_anio['anio'].$row_anio['mes']);
?>
<input type="checkbox" id="<?php echo $anomes?>"name="<?php echo $anomes?>" value="<?=$anomes?>" checked="checked" ><?=$anomes?>
<?php
}
mysql_free_result($resulset_anio );
?>
</td>
</tr>
</div>
<td colspan="3" align="left">
<a href="javascript:seleccionar_todo()">Marcar todos</a>
<a href="javascript:deseleccionar_todo()">Marcar ninguno</a>
<input type="button" value="Consultar" name="button" id="button" onclick="javascript:deseleccionar(),deselecc()">
The functions I use are these:
function deseleccionar(){
//alert(document.getElementById('aniofin').value);
var formulario = document.getElementById("form");
formulario.submit();
return true;}
function deseleccionar_todo(){
for (i=0;i<document.form.elements.length;i++)
if(document.form.elements[i].type == "checkbox")
document.form.elements[i].checked=0
}
function seleccionar_todo(){
for (i=0;i<document.form.elements.length;i++)
if(document.form.elements[i].type == "checkbox")
document.form.elements[i].checked=1
}