Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Ryukusei

3 Combobox em AJAX sem refresh na pagina inteira

Recommended Posts

Olá pessoal,Gostaria se alguem poderia me ajudar como montar 3 combobox em ajax mas em php??....... vi um tutorial em ASP mas nao sei programar em ASPcom dois combobox é sussegado mas com 3 estou apanhando se alguem souber de um tutorial ou tem um exemplo pronto por favor me passecomo exemplo para quem nao entendeu Categoria->Fabricante->Modelo Carro Fiat PalioValewsAbraços a Todos

Compartilhar este post


Link para o post
Compartilhar em outros sites

desculpa gente hehehe so novato em ajax.........eu vi um e deu pra entender mas com 2 combobox agora com 3 fica dificil pra min............o q o tmferreira passou eh usando um arquivo.txt eu precisa de um usando com o banco de dados mysql............. com os 3 combobox heheheheheheehe

Compartilhar este post


Link para o post
Compartilhar em outros sites

esse code em baixo é o ajax.js

var req;function loadXMLDoc(url){ 	req = null;	if (window.XMLHttpRequest) { 		req = new XMLHttpRequest(); 		req.onreadystatechange = processReqChange; 		req.open("GET", url, true);  		req.send(null);	} else if (window.ActiveXObject) {		try {			req = new ActiveXObject("Msxml2.XMLHTTP.4.0");		} catch(e) {			try {				req = new ActiveXObject("Msxml2.XMLHTTP.3.0");			} catch(e) {				try {					req = new ActiveXObject("Msxml2.XMLHTTP");				} catch(e) {					try {						req = new ActiveXObject("Microsoft.XMLHTTP");					} catch(e) {						req = false;					}				}			}		}		if (req) { 			req.onreadystatechange = processReqChange; 			req.open("GET", url, true); 			req.send();		}	}}function processReqChange(){	if (req.readyState == 4) {		if (req.status == 200) {			document.getElementById("atualiza").innerHTML = req.responseText;		} else {			alert("Houve um problema ao obter os dados:\n" + req.statusText);		}	}}function atualiza(valor){	loadXMLDoc("fabricante.php?ID="+valor);}

esse aki é o fabricante.php

<?//Header para evitar caheheader("Content-type: text/html; charset=iso-8859-1");header("Cache-Control: no-store, no-cache, must-revalidate");header("Cache-Control: post-check=0, pre-check=0", false);header("Pragma: no-cache");include ('includes/config.inc.php');echo "<select name=\"fabricante\">";$result = mysql_query("SELECT * FROM categoria_fabricante WHERE id_categoria= '$_GET[iD]'");while ($categoria_fabricante = mysql_fetch_object ($result)){	$sql = mysql_query("SELECT * FROM fabricante WHERE id_fabricante='$categoria_fabricante->id_categoria' ORDER BY 'nome'");	while($fabricante = mysql_fetch_array($sql)){echo "<option value=\"$fabricante[id_fabricante]\">$fabricante[nome]</option>";}}echo "</select>";?>

esse é o trecho dos selects

<tr>        <td colspan="2"><table width="669" border="1">            <tr>              <td><p><strong>Categoria:</strong><BR>                  <select name="id_categoria" class="select" id="id_categoria" onChange="atualiza(this.value);">                    <option value="#">--Selecione uma Categoria--</option>                    <?php		      	   //Mysql_Query envia uma consulta ao Mysql			  	  $result = mysql_query("SELECT * FROM categoria ORDER BY 'nome'");		  		  while($row = mysql_fetch_array($result)){		  			echo "<option value=\"$row[id_categoria]\">$row[nome]</option>";		  		  }		  		?>                  </select>              </td>              <td><strong>Fabricante:</strong><BR>                <div id="atualiza">                  <select name="fabricante" onchange="atualizam(this.value);" >                    <option value="#">--Selecione um Fabricante--</option>                  </select>                </div></td>              <td><strong>Modelo:</strong><BR>			  <div id="atualiza">                <select name="id_modelo" class="select" id="id_modelo">                  <option value="#">--Selecione um Modelo--</option>                </select>				</div></td>            </tr>          </table></td>      </tr>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.