<html>
<head>
<meta charset="utf-8">
<title>AJAX, JSON E PHP</title>
<script type="text/javascript" charset="utf-8"></script>
</head>
<body>
<select name="secoes" id="secoes" style="font-weight:bold;width:100%">
<option>Selecione...</option>
<option value="25" id="25">Hortifrutti</option>
<option value="15" id="15">Peixaria</option>
</select>
<select id="itens" name="itens" style="width:100%; font-weight:bold;">
<option>Selecione...</option>
<option value=""></option>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script>$(document).ready(function(){$('#secoes').change(function(){$('#itens').load('dados.php?secao='+$('#secoes').val());});$('#itens').change(function(){varValor=$('#itens').val();if(Valor!=''){$('#tabela').load('dados.php?ean='+$('#itens').val());}});});</script></body>
IreturnPHP
<head><?phpheader('Content-type:text/html;charset=utf-8');?><metahttp-equiv="Content-Type" content="text/html" charset="utf-8" />
<? require_once('bd.php'); ?>
</head>
<body>
<?php
//header('Content-Type: text/html; charset=utf-8');
$SecaoPadrao = $_GET['secao'];
$eanselecionado = $_GET['ean'];
if($secao!= ''){
mysql_set_charset('utf8');
$query = mysql_query("SELECT * FROM ConferenciaCeasa where secao ='$SecaoPadrao' and ForaLinha!='*' order by descricao asc");
echo "<option>Selecione...</option>";
while($row = mysql_fetch_array($query)){
echo "<option value='".$row['ean']."'>".$row['descricao']."</option>";
}
}elseif($eanselecionado!= ''){
$query = mysql_query ("select TaraQuantidade,TaraTroca from ConferenciaCeasa WHERE ean like '$eanselecionado'");
while($row = mysql_fetch_array($query)){
echo "<input type='text' style='width:100%;display:<?echo $mostra;?>' value='".$row['TaraQuantidade']."' id='tara-quantidade' name='tara-quantidade' onblur='CalculaCaixa();' onfocus='this.select()'></input>";
}
}
?>
</body>
</html>