eu segui basicamente o tutorial e apenas fiz alterações para o meu sistema, mas não obtive sucesso, pois minhas informações não retornam no segundo combo... ele fica com umas barras |||||| é bem estranho..
Alguem pode me ajudar ?
Vou por meus códigos aqui...se alguem puder me ajudar eu agradeço!
<? //Inicia a sessão session_start(); include "conectar.php"; $login_colaborador = $_SESSION['login']; ?> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="javascript"> function pesquisar_dados(valor) { http.open("GET", "consultar_tarefas.php?id=" + valor, true); http.onreadystatechange = handleHttpResponse; http.send(null); } function handleHttpResponse() { campo_select = document.forms[0].combo_tarefa_andamento; if (http.readyState == 4) { campo_select.options.length = 0; results = http.responseText.split(","); for( i = 0; i < results.length; i++) { string = results[i].split( "|" ); campo_select.options[i] = new Option( string[0], string[1] ); } } } function getHTTPObject() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; } } @else xmlhttp = false; @end @*/ if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } var http = getHTTPObject(); </script> </HEAD> <BODY> <table width="55%" align="center" border="0" height="210" > <form method="POST" action="acao_andamento.php"> <TR> <TD align="right" valign="bottom" ><font face = "verdana" size="2"><b>PROJETO:</b></font></TD> <TD valign="bottom"> <select name="combo_projeto_andamento" onchange="pesquisar_dados(this.value)"> <option></option> <?php $dados= pg_query($connect, "SELECT nm_projeto, id_projeto FROM tb_projeto ORDER BY id_projeto"); while($campo = pg_fetch_array($dados)) { ?> <option value="<?echo $campo['id_projeto']?>"><? echo $campo['nm_projeto']?></option> <? } ?> </select> </TD> </TR> <TR> <TD align="right" valign="bottom" ><font face = "verdana" size="2"><b>TAREFA:</b></font></TD> <TD valign="bottom"><select name="combo_tarefa_andamento" ></select></TD> </TR> </table> </form> </BODY> </HTML>
consultar_tarefas.php
<?php include "conectar.php"; $combo_projeto_andamento = addslashes($_GET['id']); $dados = pg_query($connect, "SELECT * FROM tb_tarefa WHERE id_projeto = '$combo_projeto_andamento' ORDER BY id_tarefa"); while( $campo = pg_fetch_assoc($dados)) { echo "<option value=\"$campo[id_tarefa]\">$campo[nm_tarefa]</option>"; } ?>