Ir para conteúdo

Arquivado

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

Morpheus#2005

Um Combo alimentar o outro

Recommended Posts

Boa noite amigos...

Sei que existe 20000000 de coisas no google falando sobre isso...mas preciso da ajujda de vcs..

 

estou me guiando por esse link Clique aqui, só que é em PHP.

 

Estou tentando fazer em ASP..

 

O que eu devo estar errando ???

 

Script Jquery

 

<script type="text/javascript">
$(document).ready(function(){     
$('#Frente').change(function(){
//alert('teste');
$('#Grupo').load('busca_grupo.asp?Frente='+$('#Frente').val());

	}); 
}); 

</script>

 

HTML OPTION

 <select name="Grupo" id="Grupo">
           <option selected="selected">Classifique..</option>

		</select>

 

 

Pagina que Busca a INFORMAÇÃO no load do JQUERY


<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/Voi_Teste.asp" -->
<%
Dim Busca_Grupo__MMColParam
Busca_Grupo__MMColParam = Request.Querystring("Frente")
%>
<%
Dim Busca_Grupo
Dim Busca_Grupo_cmd
Dim Busca_Grupo_numRows

Set Busca_Grupo_cmd = Server.CreateObject ("ADODB.Command")
Busca_Grupo_cmd.ActiveConnection = MM_Voi_Teste_STRING
Busca_Grupo_cmd.CommandText = "SELECT distinct(grupo) FROM dbo.Base_CRM where frente = ?" 
Busca_Grupo_cmd.Prepared = true
Busca_Grupo_cmd.Parameters.Append Busca_Grupo_cmd.CreateParameter("param1", 200, 1, 255, Busca_Grupo__MMColParam) ' adVarChar

Set Busca_Grupo = Busca_Grupo_cmd.Execute
Busca_Grupo_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Busca_Grupo_numRows = Busca_Grupo_numRows + Repeat1__numRows
%>


</head>

<body>
<% 
While ((Repeat1__numRows <> 0) AND (NOT Busca_Grupo.EOF)) 
%>
<%
 Response.Write "<OPTION VALUE = '" & Busca_Grupo ("Grupo") & "' SELECTED>"
     Response.Write Busca_Grupo("Grupo") & "</Option>"


 %>
           <% 
 Repeat1__index=Repeat1__index+1
 Repeat1__numRows=Repeat1__numRows-1
 Busca_Grupo.MoveNext()
Wend
%>
</body>
</html>
<%
Busca_Grupo.Close()
Set Busca_Grupo = Nothing
%>

 

VALWWWWWWWWWWWWWWWWWW

Compartilhar este post


Link para o post
Compartilhar em outros sites

olha este exemplo, usando AJAX, tem outros exemplos que postei no fórum, também faça uma procura

 

 

Default.asp

 
<html>  
<head>  
<title>Teste Combo</title>  
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />  
<script language="javascript" src="ajax.js"></script>  
</head>  
<body>  
Categoria:  
<select name="categoria" onchange="alimentarCombo(this.value);">  
   <option value="">[ Selecione ]</option>  
    <%  
    set rs = conn.execute("SELECT codigo, nome FROM categoria ORDER BY nome ASC")  
       if (not rs.eof) then  
            while (not rs.eof)  
                response.write("<option value="""&rs("codigo")&""">"&rs("nome")&"</option>")  
         rs.moveNext : wend  
       end if  
    set rs = nothing  
   %>  
</select>  
<br>  
Sub-Categoria: <div id="resultado"></div>  
</body>  
</html>  

 

ajax.js

    function GetXMLHttp() {  
     if (navigator.appName == "Microsoft Internet Explorer") {  
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");  
     } else {  
         xmlHttp = new XMLHttpRequest();  
   }  
     return xmlHttp;  
}  
 var mod = GetXMLHttp();  

function alimentarCombo(valor) {  
     mod.open("GET", "Carrega.ajax.asp?id="+valor+"", true);  
     mod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  
     mod.onreadystatechange = function() {  
         if (mod.readyState == 4) {  
             document.getElementById("resultado").innerHTML = mod.responseText;  
         }  
    };  
    mod.send(null);  
 }  

 

Carrega.ajax.asp

   <select name="sub_categoria">  
   <option value="">[ Selecione ]</option>  
    <%  
    set rs = conn.execute("SELECT codigo, nome FROM sub_categoria WHERE categoria_id = '"&request.queryString("id")&"'")  
        if (not rs.eof) then  
            while (not rs.eof)  
                response.write("<option value="""&rs("codigo")&""">"&rs("nome")&"</option>")  
            rs.moveNext :wend           end if  
    set rs = nothing  
    %>  
</select>  

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.