0
I need to take the chosen value of select and play in one query, how to do? In practice (following the example) I choose in select a driver and this select will return below all the records referring to this driver, maybe the fields can be date of the trip, vehicle, etc. (is just an example) all without a Ubmit 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 updates the page of the query, the result returns and is printed, but in printing I am not able to make the format of the loop is consistent with the table, below my files for who can help, and of course, @Thomas who has helped and a lot! (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 PRINTED RESULT (with the wrong formatting due to the TAG that needs to have the
Name of the Accredited Unit Active AOP POP APC HO PSI PSO H PS M PA HP AMB PS Inf
--> THE RESULT ON THE SCREEN
Name of Accredited Unit | Active |AOP|POP|APC|HO|PSI|PSO|H|PS|M|PA|HP|AMB|PS Inf - unit 01 | chk | ch|ch |ch |ch|ch |ch |c|ch|c|ch|ch|ch | chk - unit 02 - unit 03 etc... and chechbox (chk) are not inside the loop the units are in a single cell (I said it was ridiculous)
Thank you
Welcome to Stack Overflow. And what have you done so far? Look deeper into your question. Read [Ask] and take a [tour].
– gmsantos