Está.
Eu pensei nisso tambem e pra comprovar copiei direto do navegador.
Se precisar dos dados pra vc dar uma olhadinho nisso pra mim por favor, eu posso te passar mais tarde.
Muito obrigado pela ajuda.
Té mais
Andréia,
Então, estou tentando utilizar este código, na verdade, eu o utilizarei com banco de dados firebird, mas primeiramente resolvi deixar no MySQL pra ver se o exemplo funcionaria. Criei uma estrutura de tabela que imaginei ser igual a utilizada por você e as alterações que fiz foi com relação a URL do javascipt e tirei os order by do código sql. E assim como a colega acima, minha página fica assim: mysql.php
minha página se chama "mysql.php" e tem esse código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><?php require "conecta.php"?><script language="JavaScript" type="text/JavaScript">function carregar(){ var url; url = 'http://davila.blog.br/central/mysql.php?g_servico='+document.Cadastro.g_servico[document.Cadastro.g_servico.selectedIndex].value; document.Cadastro.especialidade.options.length = 0; addItem(document.Cadastro.especialidade,"Aguarde...carregando","",false,document.Cadastro.especialidade.length); myIframe.location = url; document.Cadastro.especialidade.focus()} function inicia(){ local1 = new Array(); var maximo1, i, campo1; local1 = myIframe.loc; campo1 = document.Cadastro.especialidade; maximo1 = local1.length; document.Cadastro.especialidade.options.length = 0; addItem(campo1,'Selecione uma especialidade','',false,campo1.length) for (i=0;i<maximo1;i++) { addItem(campo1,local1[i][1],local1[i][0],false,campo1.length); }}function addItem(obj,strText,strValue,blSel,intPos){ var newOpt,i,ArTemp,selIndex; selIndex = (blSel)?intPos:obj.selectedIndex; newOpt = new Option(strText,strValue); Len = obj.options.length+1 if (intPos > Len) return obj.options.length = Len if (intPos != Len) { ArTemp = new Array(); for(i=intPos;i<obj.options.length-1;i++) ArTemp[i] = Array(obj.options[i].text,obj.options[i].value); for(i=intPos+1;i<Len;i++) obj.options[i] = new Option(ArTemp[i-1][0],ArTemp[i-1][1]); } obj.options[intPos] = newOpt; if (selIndex > intPos) obj.selectedIndex = selIndex+1; else if (selIndex == intPos) obj.selectedIndex = intPos; } //cidadefunction carregar_cid(){ var url; url = 'http://davila.blog.br/central/remote.php?especialidade='+document.Cadastro.especialidade[document.Cadastro.especialidade.selectedIndex].value; document.Cadastro.cidade.options.length = 0; addItem(document.Cadastro.cidade,"Aguarde...carregando","",false,document.Cadastro.cidade.length); myIframe2.location = url; document.Cadastro.cidade.focus()} function inicia_cid(){ local1 = new Array(); var maximo1, i, campo1; local1 = myIframe2.loc; campo1 = document.Cadastro.cidade; maximo1 = local1.length; document.Cadastro.cidade.options.length = 0; addItem(campo1,'Todas as cidades','TODAS',false,campo1.length) for (i=0;i<maximo1;i++) { addItem(campo1,local1[i][1],local1[i][0],false,campo1.length); }}function leapto(Cadastro) { document.Cadastro.submit();}</script></head><body> <form name="Cadastro" action="lista.php" target="Cadastro" method="get"> <div style="DISPLAY: none; top:100px; left:100px; position:relative; width:400px; height:20px;"> <IFRAME src name="myIframe" id="myIframe" width="400" height="100" marginwidth="0" marginheight="0"></IFRAME> </div> <div style="DISPLAY: none; top:0px; left:-1px; position:relative; width:400px; height:20px;"> <IFRAME src name="myIframe2" id="myIframe2" width="400" height="100" marginwidth="0" marginheight="0"></IFRAME> </div><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <table width="50%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <p class="textoTitulo" align="left">Grupo de Serviços:<br> <select name="g_servico" style="WIDTH:230" onChange="carregar();"> <option value="">Selecione um Serviço</option> <?php $sql = mysql_query("SELECT DISTINCT g_servico FROM cm_convenio"); while($linha=mysql_fetch_array($sql)) { echo "<option value=\"" . $linha["g_servico"] . "\">" . $linha["g_servico"] . "</option>"; } ?> </select><br> <br> Especialidades:<br> <select name="especialidade" style="WIDTH:230" onChange="carregar_cid();"> <option value="">Selecione a Especialidade</option> </select><br> <br> Cidade:<br> <select name="cidade" style="WIDTH:230"> <option value="TODAS">Todas as cidades</option> </select> </p> <p><input type="submit" name="Submit" value=" Pesquisar " onClick="java script:Abrir();"></p> </td> </tr> </table> </td> </tr></table> </form><? require "remote.php"?></body></html>
e o este é o meu arquivo "remote.php":
<?// Conecta-se com o MySQLrequire "conecta.php";//configurações de bando de dados$g_servico = $_GET['g_servico'];$auxsql = "SELECT especialidade FROM cm_convenio WHERE g_servico='{$g_servico}'";$sql = mysql_query($auxsql);if(!$sql){echo mysql_error();exit();}echo "";?><script> loc = new Array(<?=mysql_num_rows($sql)?>) for (i=0; i < <?=mysql_num_rows($sql)?>; i++) { loc[i] = new Array(2) for (j=0; j < 2; j++) { loc[i][j] = "0" } } <? $j = 0; while ($linha = mysql_fetch_array($sql)) {?> loc[<?=$j?>][0] = "<?=$linha[0]?>"; loc[<?=$j?>][1] = "<?=$linha[0]?>"; <? $j++; } ?> parent.inicia(); <?mysql_close($dbh);?></script>
e utilizei esta estrutura para o banco de dados
CREATE TABLE 'cm_convenio' ( 'id' INTEGER(11) NOT NULL AUTO_INCREMENT, 'g_servico' INTEGER(11) DEFAULT NULL, 'especialidade' INTEGER(11) DEFAULT NULL, 'seq' INTEGER(11) DEFAULT NULL, PRIMARY KEY ('id') )
então gostaria da sua colaboração para saber onde estou comendo bola...
seria interessante também se você disponobilizasse também os fontes...
Obrigada.