I have a code that works with two dropdowns that automatically update themselves using jQuery, where when selecting one, the other is populated by doing the filter in my database. And just below, I have a table that I want to fill it with the values that will be filtered with the results chosen in the two dropdowns, and preferably done without refreshing the page. Is it possible?
I'm using non-object-oriented PHP.
Dropdowns:
<div class="col-sm-3 col-sm-offset-2">
<form action="#">
<div class="form-group">
<label id="drops-labels"><b id="centraliza-txt">REDE</b></label>
<span data-toggle="tooltip" data-placement="top" title="ESCOLHA A REDE">
<select name="estados" id="estados" class="form-control input-sm">
<option value="0">---Selecione---</option>
<?php
$result = mysql_query("select distinct Rede_m1, id_rede from indicadores_rv where Supervisor_m1 = '".$_SESSION['usuarioNome']."' order by rede_m1");
while($row = mysql_fetch_array($result) ){
echo "<option value='".$row['id_rede']."'>".$row['Rede_m1']."</option>"; }
?>
</select>
</span>
</div>
</form>
</div>
<div class="col-sm-3">
<label id="drops-labels"><b id="centraliza-txt">LOJA</b></label>
<select name="cidades" id="cidades" class='form-control input-sm'">
<option value="0">---Selecione---</option>
</select>
</div>
Calling jquery:
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#estados').change(function(){
$('#cidades').load('cidades.php?estado='+$('#estados').val() );
});
});
</script>
Cities.php
<?php
$idestado = $_GET['estado'];
require 'conecta.php';
$result = mysql_query("SELECT * FROM indicadores_rv WHERE id_rede ".$idestado);
while($row = mysql_fetch_array($result) ){
echo "<option value='".$row['id_rede']."'>".$row['Loja_m1']."</option>";
}
?>
And the table that I want to put the data (I have not yet put the variables pq I do not know how I should do in this case)
<div class="table-responsive"><!-- div de tabela responsivo -->
<table class="table table-hover table-bordered table-striped" id="tabela_formatada"> <!-- pode misturar os tables -->
<thead>
<tr>
<th id="tab3"><b> </b></th>
<th id="tab3"><b>D-1</b></th>
<th id="tab3"><b>W</b></th>
<th id="tab3"><b>M</b></th>
<th id="tab4"><b>M-1</b></th> </tr>
</thead>
<tbody>
<tr>
<td id="tab99"><b># CPF Enviados</b></td>
<td id="tab0"><b><!--variáveis aqui --></b></td>
<td id="tab0"><b><!--variáveis aqui --></b></td>
<td id="tab0"><b><!--variáveis aqui --></b></td>
<td id="tab0"><b><!--variáveis aqui --></b></td>
</tr>