Good I'm doing a form but in this case they fill certain data or they choose and a graph is generated and below a table that is basically the description of that graph and it is dynamic.
The problem is that when I press the first time it works fine but when I choose another type the table is not updated and when I click on it several times, the table is updated and it shows me.
could help me.
THE PROBLEM IS NOT THE GRAPHIC BUT THE TABLE THAT DOES NOT UPDATE WHEN I PRESS THE BUTTON
Also, when I enter the default page, the table is displayed as I could do so that when I enter the table is not visible and when I click on it, it will appear
Now I'm on the button that is on my form is the following.
<button type="button" name="btngenerargraficoporterritorio11" class="btn btn-primary" onclick="generargraficodetalleobservacion();">Generar Gráfico</button>
that is to say that when you press you call a function that is for the graphic
<script type="text/javascript">
function generargraficodetalleobservacion(){
var grafinicio=document.getElementById("txtgfinicio").value;
var graffin=document.getElementById("txtgffin").value;
var zona = document.getElementById("zonalabelidgraf").value;
var agencia = document.getElementById("agencialabelidgraf").value;
var tipoobservacion = document.getElementById("tiobselabelidgraf").value;
var producto = document.getElementById("prodlabelidgraf").value;
console.log(grafinicio);
console.log(graffin);
console.log(zona);
console.log(agencia);
console.log(tipoobservacion);
console.log(producto);
if(grafinicio=="")
{
alert("Ingrese la Fecha inicio");
}
if(graffin=="")
{
alert("Ingrese la Fecha Fin");
}
if(zona=="Seleccionar")
{
alert("Ingrese la Zona");
}
if(producto=="Seleccionar")
{
alert("Ingrese el Producto");
}
//listarUsuarios1();
//$("#tableUsersss").empty().load("Tablahistoricografico.php");
var options = {
chart: {
renderTo: 'containergrafico',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: ' '
},
tooltip: {
formatter: function() {
return '<b>' + this.point.name + '</b>: ' + this.y +'%';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>' + this.point.name + '</b>: ' + this.y +'%';
}
},
showInLegend: true
}
},
series: []
};
$.getJSON("data/detalleobservaciongrafico.php?finicio="+grafinicio+"&ffin="+graffin+"&zona="+zona+"&agencia="+agencia+"&tipoobservacion="+tipoobservacion+"&producto="+producto, function(json) {
options.series = json;
chart = new Highcharts.Chart(options);
});
listarUsuarios1();
};
</script>
Now I to generate the table I do with this script
<script>
/* Por lo que veo usas jQuery */
function listarUsuarios1() {
$.ajax({
type: 'POST',
url: 'Tablahistoricografico.php',
dataType : 'html',
success: function(data){
$('#tableUsersss').html(data);
}
});
} // listarUsuarios
/* Segun prefieras o estes más familiazado usa este */
$(function () {
listarUsuarios1();
});
/* ó; deseable no dejes ambos solo uno */
$(document).ready(function () {
listarUsuarios1();
});
</script>
that on my page that calls is this. HISTORICAL TABLE
<?php
include("config.php");
session_start();
/* Tu proceso de conexión, consulta y resultado */
$finicio = isset($_SESSION['finicio']) ? $_SESSION['finicio'] : '';
$ffin = isset($_SESSION['ffin']) ? $_SESSION['ffin'] : '';
$zona= isset($_SESSION['zona']) ? $_SESSION['zona'] : '';
$agencia = isset($_SESSION['agencia']) ? $_SESSION['agencia'] : '';
$tipoobservacion = isset($_SESSION['tipoobservacion']) ? $_SESSION['tipoobservacion'] : '';
$producto = isset($_SESSION['producto']) ? $_SESSION['producto'] : '';
$sql1 = "EXEC Sp_DetalleObservacion 2,'$finicio','$ffin','$zona','$agencia','$tipoobservacion','$producto','' ";
$result1 = sqlsrv_query($conn,$sql1) or die("Couldn't execut query");
$sql= "EXEC Sp_DetalleObservacion 7,'','','','','','','' ";
$result = sqlsrv_query($conn,$sql) or die("Couldn't execut query");
if(!$result){
echo "Ocurrio un error en la consulta";
}else{
$tabla ="<table class='table table-bordered text-center'>";
$tabla .="<thead>";
$tabla .= "<tr>";
$i = 0;
while ($data = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC)) {
if ($i == 0) {
foreach($data as $key => $value) {
$tabla .="<th scope='col' style='text-align: center;background-color: #054AC4;color: #fff'>" . utf8_decode($key) . "</th>";
}
$tabla .="</tr>";
$tabla .="</thead>";
$tabla .="<tbody>";
}
$tabla .="<tr>";
foreach($data as $key => $value) {
$tabla .="<td>".utf8_encode($value)."</td>";
}
$tabla .="</tr>";
$i++;
}
$tabla .="</tbody>";
$tabla .="</table>";
echo $tabla;
}
?>