Ir para conteúdo
Fórum Script Brasil
  • 0

Problema com List Menu Dinamico


Edhy Ghellen

Pergunta

Boa tarde, galera!

Estou com um problema que já esta me dando muita dor de cabeça.

Tenho um formulário que pede alguns dados para geração de um contrato.

Pois bem, preciso que ao selecionar o tipo de equipamento no primeiro list menu carregue as marcas no segundo list menu e ao selecionar a marca carregue os modelos no terceiro list menu.

Até conseguir carregar as marcas eu consegui, mas não estou conseguindo popular o terceiro list menu com os modelos.

Segue os códigos:

monta_contrato.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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>Untitled Document</title>
<!-- #include file="../regras.css" -->
<!-- #include file="../funcoes/conexao.asp" -->
<script language="javascript">
function showCustomer(str, tipo) {

if (tipo == "marca") {
    if (str=="")  {
       document.getElementById("mostra_marca").innerHTML="";
       return false;
    }
    xmlhttp=new XMLHttpRequest();
    xmlhttp.onreadystatechange=function()
       {
       if (xmlhttp.readyState==4 && xmlhttp.status==200)
          {
          document.getElementById("mostra_marca").innerHTML=xmlhttp.responseText;
          }
       }

    xmlhttp.open("GET","mostra_marca.asp?q="+str,true);
    xmlhttp.send();
    }
 else {
if (tipo == "modelo") {
    if (str=="")  {
       document.getElementById("mostra_modelo").innerHTML="";
       return false;
    }
    xmlhttp=new XMLHttpRequest();
    xmlhttp.onreadystatechange=function()
       {
       if (xmlhttp.readyState==4 && xmlhttp.status==200)
          {
          document.getElementById("mostra_modelo").innerHTML=xmlhttp.responseText;
          }
       }

    xmlhttp.open("GET","mostra_modelo.asp?q="+str,true);
    xmlhttp.send();
    }
 }
}
</script>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3"><table bgcolor="#000000" width="100%" border="0">
      <tr>
        <td width="160"><img src="../imagens/logo/logo.jpg" width="160" height="100" /></td>
        <td align="center"><font color="#FFFFFF"><strong>PAINEL DE CONTROLE</strong></font></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="15%" valign="top">&nbsp;</td>
    <td>&nbsp;</td>
    <td width="5%">&nbsp;</td>
  </tr>
  <tr>
    <td width="160" valign="top"><!-- #include file="menu_painel.asp" --></td>
    <td align="center" valign="top"><table width="90%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td bgcolor="#000000"><font color="#FFFFFF"><strong>NOVO CONTRATO</strong></font></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><p>Você está iniciando um novo contrato para:</p>
        
        <%
		
		codigo_cli = request.QueryString("cliente")
		
		If codigo_cli < 5000 Then
		
		sqlCons = "SELECT nome_cf FROM cliente_fisico WHERE codigo_cf = '" & codigo_cli & "'"
		
		set rsCons = Conn.Execute(sqlCons)
		
		DO WHILE NOT rsCons.eof
		
		nome_cli = rsCons("nome_cf")
		
		rsCons.movenext
		LOOP
		rsCons.close
		set rsCons = nothing
		
		Else
		
		sqlCons = "SELECT fantasia_cj FROM cliente_juridico WHERE codigo_cj = '" & codigo_cli & "'"
		
		set rsCons = Conn.Execute(sqlCons)
		
		DO WHILE NOT rsCons.eof
		
		nome_cli = rsCons("fantasia_cj")
		
		rsCons.movenext
		LOOP
		rsCons.close
		set rsCons = nothing

		End If
		
		%>
          <p><% =nome_cli %></p></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td bgcolor="#000000"><font color="#FFFFFF"><strong>DADOS NECESSÁRIOS</strong></font></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><form id="form1" name="form1" method="post" action="../funcoes/monta_contrato.asp">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="33%" bgcolor="#CCCCCC">Quantidade:</td>
              <td width="67%" bgcolor="#CCCCCC"><label for="txt_quantidade"></label>
                <input type="text" name="txt_quantidade" id="txt_quantidade" /></td>
              </tr>
            <tr>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              </tr>
            <tr>
              <td bgcolor="#CCCCCC">Equipamento</td>
              <td bgcolor="#CCCCCC"><label for="txt_equipamento"></label>
                <select name="txt_equipamento" id="txt_equipamento" onchange="showCustomer(this.value,'marca')" >
                <%
				encheEquip = "SELECT DISTINCT(equipamento_pl) FROM produtos_locacao ORDER BY equipamento_pl ASC"
				set rsEncEqui = Conn.execute(encheEquip)
				
				DO WHILE NOT rsEncEqui.eof 
				%>
                  <option value="<% =rsEncEqui("equipamento_pl") %>"><% =rsEncEqui("equipamento_pl") %></option>
                  <%
				  rsEncEqui.movenext
				  LOOP
				  rsEncEqui.close
				  set rsEncEqui = nothing
				  %>
                </select></td>
              </tr>
            <tr>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              <td bgcolor="#CCCCCC">&nbsp;</td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">Marca</td>
              <td bgcolor="#CCCCCC"><div id="mostra_marca" name="mostra_marca">
                <label for="txt_marca"></label>
                <select name="txt_marca" id="txt_marca"  onchange="showCustomer(this.value,'modelo')">
                </select></div></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              <td bgcolor="#CCCCCC">&nbsp;</td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">Modelo</td>
              <td bgcolor="#CCCCCC"><div id="mostra_modelo" name="mostra_modelo"><label for="txt_modelo"></label>
                <select name="txt_modelo" id="txt_modelo">
                </select></div></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              <td bgcolor="#CCCCCC">&nbsp;</td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">Franquia</td>
              <td bgcolor="#CCCCCC"><input type="text" name="txt_franquia" id="txt_franquia" /></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              <td bgcolor="#CCCCCC">&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">Valor</td>
              <td bgcolor="#CCCCCC"><label for="txt_valor"></label>
                <input type="text" name="txt_valor" id="txt_valor" /></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">Valor Extenso</td>
              <td bgcolor="#CCCCCC"><label for="txt_valorext"></label>
                <input type="text" name="txt_valorext" id="txt_valorext" /></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              <td bgcolor="#CCCCCC">&nbsp;</td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">Valor Página Extra</td>
              <td bgcolor="#CCCCCC"><label for="txt_pgextra"></label>
                <input type="text" name="txt_pgextra" id="txt_pgextra" /></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">Valor Extenso</td>
              <td bgcolor="#CCCCCC"><label for="txt_pgextraext"></label>
                <input type="text" name="txt_pgextraext" id="txt_pgextraext" /></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              <td bgcolor="#CCCCCC">&nbsp;</td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">Inicio do Contrato</td>
              <td bgcolor="#CCCCCC"><label for="txt_inicio"></label>
                <input type="text" name="txt_inicio" id="txt_inicio" /></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              <td bgcolor="#CCCCCC">&nbsp;</td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">Vencimento Boleto</td>
              <td bgcolor="#CCCCCC"><label for="txt_vencimento"></label>
                <select name="txt_vencimento" id="txt_vencimento">
                  </select></td>
            </tr>
            <tr>
              <td bgcolor="#CCCCCC">&nbsp;</td>
              <td bgcolor="#CCCCCC"><input name="txt_empresa" type="hidden" id="txt_empresa" value="<% =codigo_cli %>" /></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><input type="image" src="../imagens/clientes/salvar_contrato.png" width="200" height="70" alt="Salvar" value="submit" /></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table>
        </form></td>
      </tr>
    </table>      <p>&nbsp;</p></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#000000" colspan="3">&nbsp;</td>
  </tr>
</table>
</body>
</html>

mostra_marca.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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>Untitled Document</title>
<!-- #include file="../funcoes/conexao.asp" -->
</head>

<body>
<%
sql="SELECT DISTINCT(marca_pl) FROM produtos_locacao WHERE equipamento_pl='" & request.QueryString("q") & "' ORDER BY marca_pl ASC"

set rs = Conn.execute(sql)
%>
<select name="txt_marca" onchange="showCustomer(this.value,'modelo')"  >
<option value="" selected>Selecione</option>
<%
DO WHILE NOT rs.EOF
%>
<option value="<%= rs("marca_pl") %>"><%= rs("marca_pl") %></option>
<%
rs.MoveNext
LOOP
rs.close
Set rs =nothing
%>
</select>
</body>
</html>

mostra_modelo.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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>Untitled Document</title>
<!-- #include file="../funcoes/conexao.asp" -->
</head>

<body>
<%
sql="SELECT DISTINCT(modelo_pl) FROM produtos_locacao WHERE equipamento_pl=" & request.QueryString("z") & "' AND marca_pl='" & request.QueryString("q") & "'" 

set rs = Conn.execute(sql)
%>
<select name="txt_modelo">
<option value="" selected>Selecione</option>
<%
DO WHILE NOT rs.EOF
%>
<option value="<%= rs("modelo_pl") %>"><%= rs("modelo_pl") %></option>
<%
rs.MoveNext
LOOP
rs.close
Set rs =nothing
%>
</select>
</body>
</html>

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...