0
I’m with two Selects on the page that are interdependent.
In the first SELECT I select the Flag and on according to all the stores that belong to that flag. And I have a third field where I wish to store the ID of the selected store. Only when I visualize in the browser, come the two Combo Boxes (SELECT), but the field INPUT TEXT won’t come.
When I select the first Combo Box, the returned URL is ?fnc=gfi&ans=14&bandorc=47 and is automatically appearing set to company 11 on INPUT TEXT.
When I select the second Combo Box, the returned URL is ?fnc=gfi&ans=14&emp=4 and the INPUT TEXT.
If I run the query in Phpmyadmin the result is this:
My code is like this:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('input[type=radio]').change(function() {
$('input[type=radio]:checked').not(this).prop('checked', false);
});
});
</script>
<form id="frmCad" name="frmCad" style="float:left; margin-top:0px;" method="post" action="../inc/processa.php?modo=incluir&fnc=<?php echo $fnc; ?>&ans=<?php echo $linha; ?>">
<p>
<input name="emp" type="hidden" value="<?php echo $emp; ?>" />
<input name="projeto" type="hidden" value="Budget" />
<input name="exercicio" type="hidden" value="<?php echo $basebud; ?>" />
<input name="linhabud" type="hidden" value="<?php echo $linha; ?>" />
<input name="usuario" type="hidden" value="<?php echo $usuario; ?>" />
<div><label for="nome">Anterior: </label>
<?php
include("../libraries/anterior.php");
?>
<fieldset style="padding:8px; margin:15px 0px 25px 0px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="30%">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option value="">Selecione a Bandeira</option>
<?php
$qry="SELECT sjy_empresas.bandeira AS id_bandeira, sjy_bandeira.bandeira
FROM kcb_tbstates
INNER JOIN sjy_bandeira
INNER JOIN sjy_grupo
INNER JOIN sjy_empresas ON sjy_grupo.id_grupo = sjy_empresas.grupo
AND sjy_bandeira.id_bandeira = sjy_empresas.bandeira
AND kcb_tbstates.ID = sjy_empresas.estado
WHERE sjy_empresas.grupo = '$grupo'
GROUP BY sjy_empresas.bandeira, sjy_bandeira.bandeira";
// Executa a consulta OU mostra uma mensagem de erro
$rs = $MySQLi->query($qry) OR trigger_error($MySQLi->error, E_USER_ERROR);
// Faz um loop, passando por todos os resultados encontrados
while ($dt = $rs->fetch_object()) {
$band = $dt->id_bandeira;
$bandeira = $dt->bandeira;
echo "<option value='premorc.php?fnc=$fnc&ans=$linha&bandorc=$band' ".($bandorc==$band?"selected":"").">$bandeira</option>";
}
?>
</select>
<!--</form>-->
</td>
<td width="*">
<!--- <form method="get" name="tLoja" id="cLoja" style="float:left; padding-left:15px;margin-top:0px;"> -->
<select name="menu2" onChange="MM_jumpMenu('parent',this,0)">
<option value="">Selecione primeiro a Bandeira</option>
<?php
$sql="SELECT sjy_empresas.id_empresa, sjy_empresas.nick, sjy_empresas.bandeira
FROM sjy_empresas
WHERE sjy_empresas.grupo = $grupo
AND bandeira = $bandorc";
// Executa a consulta OU mostra uma mensagem de erro
$rset = $MySQLi->query($sql) OR trigger_error($MySQLi->error, E_USER_ERROR);
// Faz um loop, passando por todos os resultados encontrados
while ($dt = $rset->fetch_object()) {
$emprsel = $dt->id_empresa;
$nicksel = $dt->nick;
echo "<option value='premorc.php?fnc=". $fnc . "&ans=" . $linha . "&emp=" . $emprsel . "'>" . $nicksel . "</option>";
}
?>
</select>
</form>
</td>
</tr>
</table>
<form action="../inc/processa.php" method="post">
<input name="emp" type="text" value="<?php echo $emprsel; ?>" /> - Filial da Premissa: <?php echo $nicksel; ?>
</form>
And jQuery does it? Where is it?
– Sr. André Baill
Hello André. Thank you for the answer. I edited the question so that now contemplated the Jquery
– Webster Moitinho