Ir para conteúdo
Fórum Script Brasil

michael.machado

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre michael.machado

michael.machado's Achievements

0

Reputação

  1. Problema no codigo. quando seleciono a primeira vez o combolist ele filtra para o segundo e terceiro combo. mais quando adiciono a outra linha ele mostra a tabela do primeiro combolist mas não atualiza o segundo e terceiro combo. abaixo codigo. <!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=utf-8" /> <title>Documento sem título</title> </head> <script type="text/javascript" src="JavaScripts/jquery-1.8.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ // Evento change no campo tipo $("select[name=tipo]").change(function(){ // Exibimos no campo marca antes de concluirmos $("select[name=marca]").html('<option value="">Carregando...</option>'); // Exibimos no campo marca antes de selecionamos a marca, serve também em caso // do usuario já ter selecionado o tipo e resolveu trocar, com isso limpamos a // seleção antiga caso tenha feito. $("select[name=modelo]").html('<option value="">Aguardando marca...</option>'); // Passando tipo por parametro para a pagina ajax-marca.php $.post("ajax-marca.php", {tipo:$(this).val()}, // Carregamos o resultado acima para o campo marca function(valor){ $("select[name=marca]").html(valor); } ) }) // Evento change no campo marca $("select[name=marca]").change(function(){ // Exibimos no campo modelo antes de concluirmos $("select[name=modelo]").html('<option value="">Carregando...</option>'); // Passando marca por parametro para a pagina ajax-modelo.php $.post("ajax-modelo.php", {marca:$(this).val()}, // Carregamos o resultado acima para o campo modelo function(valor){ $("select[name=modelo]").html(valor); } ) }) }) </script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript"> $(function () { function removeCampo() { $(".removerCampo").unbind("click"); $(".removerCampo").bind("click", function () { if($("tr.linhas").length > 1){ $(this).parent().parent().remove(); } }); } $(".adicionarCampo").click(function () { novoCampo = $("tr.linhas:first").clone(); novoCampo.find("input").val(""); novoCampo.insertAfter("tr.linhas:last"); $(this).parent().parent().load(); removeCampo(); }); }); </script> <style type="text/css"> body { margin: 0px 0px 0px 0px; text-align: center; } </style> </head> <body> <table width="633" height="54" id="banner" border="0" cellspacing="1"> <tr class="linhas"> <th width="607" height="24" bgcolor="#FEF8E9" id="banner" scope="col"><div align="left"> <p> <select name="tipo" id="tipo[]0" onclique ="clone" > <option value="0">Escolher tipo</option> <?php include "conexao_combo.php"; $sql = "SELECT * FROM tbl_tipo ORDER BY tipo ASC"; $qr = mysql_query($sql) or die(mysql_error()); while($ln = mysql_fetch_assoc($qr)){ echo '<option value="'.$ln['t'].'">'.$ln['tipo'].'</option>'; } ?> </select> <select name="marca" id="marca"> <option value="0" selected="selected">Aguardando tipo...</option> </select> <select name="modelo"> <option value="0" selected="selected">Aguardando marca...</option> </select> </p> </div></th> <th width="5" bgcolor="#FEF8E9" scope="col"><a href="#" class="removerCampo" title="Remover linha"><img src="img/minus.png" width="22" height="22" border="0" align="right" /></a></th> </tr> <th height="24" scope="col"><a href="#" class="adicionarCampo" title="Adicionar item"><img src="img/plus.png" width="22" height="22" border="0" align="left" /></a></th> <th scope="col">&nbsp;</th> </tr> </table> </body> </html>
×
×
  • Criar Novo...