I need to get the selected value of the select and play in a query , how do I? In practice (following the example) I choose to select a driver and this select will return below all the records regarding this driver, maybe the fields could be date of trip, vehicle, etc ... (it's just an example), all this without a submit button or any other.
I have the following select list:
<select name="regiao" onchange="run()" id="regiao">
<option value="0" selected="selected">Escolha a Região</option>
<?php
//listar regioes
$db->select_pdo("SELECT * FROM regiaos order by indOrdem ASC");
foreach($db->result as $value){
echo '<option value="'.$value['idRegiao'].'">'.$value['txtDescricao'].'</option>';
}
?>
</select>
E o Javascript:
<script>
function run() {
document.getElementById("rstregiao").value = document.getElementById("regiao").value;
}
</script>
E o resultado (que imprime o html c o valor correto, porém eu precisaria do valor sem o html para rodar a variável na query):
<?php
$regiaos = '<input type="text" id="rstregiao" placeholder="valor">';
echo $regiaos;
//listar redecredenciadas
$db->select_pdo("SELECT * FROM redecredenciadas WHERE idRegiao = '$regiaos' order by txtNome ASC");
foreach($db->result as $value){
unset($credenciada);
$credenciada = $value['txtNome'];
echo $credenciada; }
?>
----- >
Now I have the following situation:
COMBO refreshes the query page, the result returns and is printed, but in printing I can not make the formatting of the loop consistent with the table, below my files for anyone who can help, and of course @ Thomas also has helped and much! (Thank you very much)
- > JAVASCRIPT
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script><script>$(document).ready(function(e){$("body").delegate("#regiao", "change", function(data){
//Pegando o valor do select
var valor = $(this).val();
//Enviando o valor do meu select para ser processado e
//retornar as informações que eu preciso
$("#conteudo").load("regiaos.php?parametro="+ valor);
});
});
</script>
- > QUERY PAGE
<?php
include ("conn.php");
$parametro = $_GET['parametro'];
$db->select_pdo("SELECT * FROM redecredenciadas WHERE idRegiao = '$parametro' ORDER BY idRegiao ASC");
foreach($db->result as $value){
echo '<tr>
<td>- '.$value['txtNome'].'</td>';
}
?>
- > PAGE WITH THE PRINTED RESULT (with the wrong formatting for the TAG that needs to have
Accredited Unit Name Active AOP Pop APC HO PSI PSO H Ps M PAN Hp AMB PS Inf
- > THE RESULT IN THE SCREEN
Accredited Unit Name | Active | AOP | POP | APC | HO | PSI | PSO | H | PS | M | PA | HP | AMB | PS Inf - unit 01 | chk | ch | ch | ch | ch | ch | ch | ch | ch | ch | ch | ch | ch | chk - unit 02 - unit 03 etc ... and the chechbox (chk) are not inside the loop the units are in a single cell (I said it was ridiculous)
Thank you