les dejo el codigo para cualquier cosa
index.php
Código PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Charting</title>
<link href="css/basic.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://filamentgroup.github.com/EnhanceJS/enhance.js"></script>
<script type="text/javascript" src="js/proceso.js" ></script>
<script type="text/javascript">
</head>
<body>
<form id="frm" name="frm" method="post">
<label>Seleccione una sucursal</label>
<select id="sucursal" name="sucursal">
<?php
include "combo.php"
?>
</select>
<input type="button" id="mostrar" value="Mostrar tabla" onClick="ShowSelected()">
<table id="destino" name="destino">
<caption>Departamento de ventas</caption>
<thead>
<tr>
<td></td>
<th scope="col">Fecha Emision</th>
<th scope="col">actual</th>
<th scope="col">dia anterior</th>
<th scope="col">semana anterior</th>
<th scope="col">Año anterior</th>
<th scope="col">bis anterior</th>
</tr>
</thead>
<tbody>
<?php include "tabla.php" ?>
</tbody>
</table>
</form>
</body>
</html>
Código PHP:
<?php
include_once 'conexion.php';
$link=conexion();
$sql="select Sucursal, Nombre from Sucursal";
$resultado = sqlsrv_query($link,$sql);
if( $resultado === false)
{
die( print_r( sqlsrv_errors(), true) );
}
while($row=sqlsrv_fetch_array($resultado, SQLSRV_FETCH_ASSOC))
{
echo "<option value=".$row['Sucursal'].">",$row['Sucursal'],' ', $row['Nombre'],' ',"</option> ";
}
?>
Código PHP:
<?php
include_once ('conexion.php');
$link=conexion();
$Sucursal = intval($_REQUEST['Sucursal']);
$sql = "select Sucursal.Nombre, VentasSucursal.FechaEmision, VentasSucursal.VentaActual, VentasSucursal.VentasDiaAnt,
VentasSucursal.VentasSemAnt, VentasSucursal.VentasAnoAnt, VentasSucursal.VentasBisAnt
from VentasSucursal inner join Sucursal on VentasSucursal.Sucursal = Sucursal.Sucursal
where VentasSucursal.Sucursal = $Sucursal";
$resultado = sqlsrv_query($link,$sql);
while($row=sqlsrv_fetch_array($resultado, SQLSRV_FETCH_ASSOC))
{
echo "<tr>";
echo "<th scope='cool'>".$row['Nombre']."</th>";
echo "<td>",$row['FechaEmision']->format('d-m-Y')."</td>";
echo "<td>",$row['VentaActual'],"</td>";
echo "<td>",$row['VentasDiaAnt'],"</td>";
echo "<td>",$row['VentasSemAnt'],"</td>";
echo "<td>",$row['VentasAnoAnt'],"</td>";
echo "<td>",$row['VentasBisAnt'],"</td>";
echo "</tr>";
}
?>
Código Javascript:
Ver original
function ShowSelected() { var posicion=document.getElementById('sucursal').options.selectedIndex; var val=document.getElementById('sucursal').value; if(val) { $.post("tabla.php",{Sucursal:val},function(resultado) { $('#destino').html(resultado); }); } } enhance({ loadScripts: [ 'js/excanvas.js', 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js', 'js/visualize.jQuery.js', 'js/example.js' ], loadStyles: [ 'css/visualize.css', 'css/visualize-light.css' ] });
Se que es mucho codigo y les pido disculpas por eso.
Cabe mencionar tambien que me envia este mensaje
Notice: Undefined index: Sucursal en el documento tabla.php linea 6 aparte de eso no me tira ningun error
Si me puediran ayudar se los agradeceria