Solved

Dynamic drop down menu

Posted on 2004-04-30
17
467 Views
Last Modified: 2008-02-01
HELLO

i HAVE THIS CODE, BUT I DON´T WANT TO HAVE TO CLICK THE OK BUTTON TO MAKE CHANGES AT THE DROP DOWN MENUS,  HOW CAN I MAKE IT AUTOMATICALLY, ONCE THE FIRST ONE CHANGES, THE SECOND DOES GIVE ME ONLY THE INFO BELONGING TO IT AUTOMATICALLY AND THE THIRD ONE THE SAME???



<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%Option Explicit%>
<%Response.Buffer = True%>
<html>
<head>
<title>Menu Prueba</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; color: #993333; }
-->
</style>
</head>
<%

 

Dim strDataPath, strConnectString, objConnection
Dim strSistema, strEquipo, strElemento, objRS, strSelected, strSQL

 

strSistema = Request.Form("Sistema")
strEquipo = Request.Form("Equipo")
strElemento = Request.Form("Elemento")

 

'set connection strings for entire application

 

strDataPath = Server.MapPath("analisis.mdb")
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;"_
            + " Data Source= " & strDataPath & ";"
           
       
If Not IsObject("ojbConnection") Then
    Set objConnection=Server.CreateObject("ADODB.Connection")
    objConnection.ConnectionTimeout = 15
    objConnection.CommandTimeout = 10
    objConnection.Mode = 3 'adModeReadWrite
    If objConnection.state = 0 Then
        objConnection.Open strConnectString
    End If
End If

 

%>

 

<%

 

Sub makeSistema()

 

    If Not IsObject("objRS") Then
        Set objRS=Server.CreateObject("ADODB.RecordSet")
    End If
    If objRS.state <> 0 Then
        objRS.close
    End If
    strSQL = "SELECT Sis_Codi FROM Sistemas"
    objRS.Open strSQL,objConnection,3,3
    Response.Write("<option></option>" & vbCrLf )
    Do While Not objRS.EOF

 

        If objRS("Sis_Codi") = strSistema Then
            strSelected = " Selected "
        Else
            strSelected = ""
        End If

 

        Response.Write("<option" & strSelected & ">" &_
                 objRS("Sis_Codi") & "</option>" & vbCrLf )
        objRS.MoveNext

 

    Loop

 

    objRS.Close
    Set objRS=Nothing
End Sub
%>
<%

 

Sub makeEquipo()
    If strSistema <> "" Then
        If Not IsObject("objRS") Then
            Set objRS=Server.CreateObject("ADODB.RecordSet")
        End If

 

        If objRS.state <> 0 Then
            objRS.close
        End If

 

        strSQL ="SELECT Equ_Codi FROM Equipos WHERE Sis_Codi = '" &_
                 strSistema & "' ORDER BY Equ_Codi"
        objRS.Open strSQL,objConnection,3,3

 

        If objRS.eof Then
            Response.Write("<option>No Se Encontraron Equipos</option>")
        Else
            Response.Write("<option>Seleccione un Equipo Ahora</option>" & vbCrLf )

 

            Do While Not objRS.EOF
                If objRS("Equ_Codi") = strEquipo Then
                    strSelected = " Selected "
                Else
                   strSelected = ""
                End If

 

                Response.Write("<option" & strSelected & ">" &_
                         objRS("Equ_Codi") & "</option>" & vbCrLf )
                objRS.MoveNext

 

            Loop

 

        End If
        objRS.Close
        Set objRS=Nothing

 

    Else
        Response.Write("<option>Seleccione un Equipo Primero </option>")
    End If

 

End Sub

 

Sub makeElemento()
    If strEquipo <> "Seleccione un Sistema Primero" And _
     strEquipo <> "Seleccione un Elemento Ahora" And strEquipo <>"" Then
        If Not IsObject("objRS") Then
            Set objRS=Server.CreateObject("ADODB.RecordSet")
        End If

 

        If objRS.state <> 0 Then
            objRS.close
        End If

 

        strSQL = "SELECT Equ_Desc FROM Equipos WHERE Equ_Codi = '" &_
                 strEquipo & "' ORDER BY Equ_Codi"
        objRS.Open strSQL,objConnection,3,3

 

        If objRS.eof Then
            Response.Write("<option>No Descriptions Found</option>")
        Else

 

            Response.Write("<option>Select Description Now</option>" & vbCrLf )
            Do While Not objRS.EOF
                If objRS("Equ_Desc") = strElemento Then
                    strSelected = " Selected "
                Else
                    strSelected = ""
                End If
                Response.Write("<option" & strSelected & ">" &_
                         objRS("Equ_Desc") & "</option>" & vbCrLf )
                objRS.MoveNext
            Loop

 

        End If
        objRS.Close
        Set objRS=Nothing

 

    Else
        Response.Write("<option>Select a Region First</option>")
    End If

 

End Sub
%>

 

<SCRIPT LANGUAGE=javascript>
<!--
Function submitSistema(){
    var objForm = document.forms[0];
    objForm.elements['Equipo'].selectedIndex=0;
    objForm.elements['Elemento'].selectedIndex = 0;
    objForm.submit();

 

}

 

Function submitEquipo(){
    var objForm = document.forms[0];
    objForm.elements['Elemento'].selectedIndex = 0;
    objForm.submit();

 

}
//-->
</SCRIPT>

 

<SCRIPT LANGUAGE=javascript>

 

<!--

 

Function submitForm(){

 

    var objForm = document.forms[0];

 

    objForm.action = "http://localhost/mantenimiento/Test/menustest.asp"

 

    return true;

 

}

 

//-->

 

</SCRIPT>
<body>
<FORM action="" method=POST id=form1 name=form1 onSubmit="return submitForm()">
  <table width="80%"  border="0">
    <tr>
      <td width="44%"><span class="style3">Sistema</span></td>
      <td width="56%"><select name="Sistema" onChange="submitSistema()">
        <%call makeSistema%>
      </select>
      <input type="submit" value="OK" id=submit12 name=submit1></td>
    </tr>
    <tr>
      <td><span class="style3">Equipos</span></td>
      <td><select name="Equipo" onChange="submitEquipo()">
        <%call makeEquipo%>
      </select>
      <input type="submit" value="OK" id=submit1 name=submit12></td>
    </tr>
    <tr>
      <td><span class="style3">Elementos a Gr&aacute;ficar </span></td>
      <td><select name="Elemento">
        <%call makeElemento%>
      </select>
      <input type="submit" value="OK" id=submit13 name=submit13></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</FORM>

 

</BODY>

 

<%
objConnection.Close
Set objConnection = Nothing
%>
</html>

 

Thank you for your help!

0
Comment
Question by:pilarvalsala
  • 6
  • 5
  • 4
  • +1
17 Comments
 
LVL 3

Expert Comment

by:zastil
Comment Utility
If its just that you do not want to push the okay button then onChange event on each combo redirecting back to itself passing the combo value.

But you can also use JavaScript todo it without reloading the page like so. This example is locations but you can replace it with your Sistema, Equipos and Elementos fields

<SCRIPT>var ESTATESLIST = new Array(); ESTATESLIST[0] = new Array(); ESTATESLIST[0][0] = '1'; ESTATESLIST[0][1]= new Array(); ESTATESLIST[0][1][0]= '1'; ESTATESLIST[0][1][1]= 'Andalucia'; ESTATESLIST[0][2]= new Array(); ESTATESLIST[0][2][0]= '4'; ESTATESLIST[0][2][1]= 'Comunidad Valenciana'; ESTATESLIST[1] = new Array(); ESTATESLIST[1][0] = '4'; ESTATESLIST[1][1]= new Array(); ESTATESLIST[1][1][0]= '7'; ESTATESLIST[1][1][1]= 'Provence Alpes Côte d`Azur';var CS_ESTATESLIST = ESTATESLIST;ESTATESLIST = null;</SCRIPT><SCRIPT>var AREASLIST  = new Array(); AREASLIST [0] = new Array(); AREASLIST [0][0] = '7'; AREASLIST [0][1]= new Array(); AREASLIST [0][1][0]= '7'; AREASLIST [0][1][1]= 'Alpes-Maritimes'; AREASLIST [1] = new Array(); AREASLIST [1][0] = '4'; AREASLIST [1][1]= new Array(); AREASLIST [1][1][0]= '5'; AREASLIST [1][1][1]= 'Costa Blanca'; AREASLIST [2] = new Array(); AREASLIST [2][0] = '1'; AREASLIST [2][1]= new Array(); AREASLIST [2][1][0]= '1'; AREASLIST [2][1][1]= 'Costa del Sol';var CS_AREASLIST = AREASLIST;AREASLIST = null;</SCRIPT><SCRIPT>var CITIESLIST  = new Array(); CITIESLIST [0] = new Array(); CITIESLIST [0][0] = '7'; CITIESLIST [0][1]= new Array(); CITIESLIST [0][1][0]= '115'; CITIESLIST [0][1][1]= 'Agen'; CITIESLIST [0][2]= new Array(); CITIESLIST [0][2][0]= '66'; CITIESLIST [0][2][1]= 'Aix-en-provence'; CITIESLIST [1] = new Array(); CITIESLIST [1][0] = '5'; CITIESLIST [1][1]= new Array(); CITIESLIST [1][1][0]= '101'; CITIESLIST [1][1][1]= 'Albir'; CITIESLIST [2] = new Array(); CITIESLIST [2][0] = '1'; CITIESLIST [2][1]= new Array(); CITIESLIST [2][1][0]= '17'; CITIESLIST [2][1][1]= 'Alhaurin'; CITIESLIST [3] = new Array(); CITIESLIST [3][0] = '5'; CITIESLIST [3][1]= new Array(); CITIESLIST [3][1][0]= '45'; CITIESLIST [3][1][1]= 'Alicante'; CITIESLIST [3][2]= new Array(); CITIESLIST [3][2][0]= '47'; CITIESLIST [3][2][1]= 'Altea'; CITIESLIST [4] = new Array(); CITIESLIST [4][0] = '7'; CITIESLIST [4][1]= new Array(); CITIESLIST [4][1][0]= '67'; CITIESLIST [4][1][1]= 'Antibes'; CITIESLIST [4][2]= new Array(); CITIESLIST [4][2][0]= '111'; CITIESLIST [4][2][1]= 'Bar Sur Loup'; CITIESLIST [5] = new Array(); CITIESLIST [5][0] = '1'; CITIESLIST [5][1]= new Array(); CITIESLIST [5][1][0]= '54'; CITIESLIST [5][1][1]= 'Benahavis'; CITIESLIST [5][2]= new Array(); CITIESLIST [5][2][0]= '31'; CITIESLIST [5][2][1]= 'Benalmadena'; CITIESLIST [6] = new Array(); CITIESLIST [6][0] = '5'; CITIESLIST [6][1]= new Array(); CITIESLIST [6][1][0]= '50'; CITIESLIST [6][1][1]= 'Benidorm'; CITIESLIST [6][2]= new Array(); CITIESLIST [6][2][0]= '56'; CITIESLIST [6][2][1]= 'Benissa'; CITIESLIST [6][3]= new Array(); CITIESLIST [6][3][0]= '59'; CITIESLIST [6][3][1]= 'Benitachell'; CITIESLIST [7] = new Array(); CITIESLIST [7][0] = '7'; CITIESLIST [7][1]= new Array(); CITIESLIST [7][1][0]= '68'; CITIESLIST [7][1][1]= 'Biot'; CITIESLIST [7][2]= new Array(); CITIESLIST [7][2][0]= '69'; CITIESLIST [7][2][1]= 'Bourgogne '; CITIESLIST [8] = new Array(); CITIESLIST [8][0] = '1'; CITIESLIST [8][1]= new Array(); CITIESLIST [8][1][0]= '22'; CITIESLIST [8][1][1]= 'Cabopino'; CITIESLIST [9] = new Array(); CITIESLIST [9][0] = '7'; CITIESLIST [9][1]= new Array(); CITIESLIST [9][1][0]= '70'; CITIESLIST [9][1][1]= 'Cagnes Sur Mer'; CITIESLIST [10] = new Array(); CITIESLIST [10][0] = '1'; CITIESLIST [10][1]= new Array(); CITIESLIST [10][1][0]= '6'; CITIESLIST [10][1][1]= 'Calahonda'; CITIESLIST [11] = new Array(); CITIESLIST [11][0] = '5'; CITIESLIST [11][1]= new Array(); CITIESLIST [11][1][0]= '42'; CITIESLIST [11][1][1]= 'Calpe'; CITIESLIST [12] = new Array(); CITIESLIST [12][0] = '7'; CITIESLIST [12][1]= new Array(); CITIESLIST [12][1][0]= '71'; CITIESLIST [12][1][1]= 'Cannes'; CITIESLIST [12][2]= new Array(); CITIESLIST [12][2][0]= '72'; CITIESLIST [12][2][1]= 'Cavalaire'; CITIESLIST [12][3]= new Array(); CITIESLIST [12][3][0]= '73'; CITIESLIST [12][3][1]= 'Chateauneuf De Grasse'; CITIESLIST [13] = new Array(); CITIESLIST [13][0] = '5'; CITIESLIST [13][1]= new Array(); CITIESLIST [13][1][0]= '44'; CITIESLIST [13][1][1]= 'Denia'; CITIESLIST [14] = new Array(); CITIESLIST [14][0] = '1'; CITIESLIST [14][1]= new Array(); CITIESLIST [14][1][0]= '37'; CITIESLIST [14][1][1]= 'Duquesa'; CITIESLIST [15] = new Array(); CITIESLIST [15][0] = '5'; CITIESLIST [15][1]= new Array(); CITIESLIST [15][1][0]= '100'; CITIESLIST [15][1][1]= 'El Campello'; CITIESLIST [16] = new Array(); CITIESLIST [16][0] = '1'; CITIESLIST [16][1]= new Array(); CITIESLIST [16][1][0]= '24'; CITIESLIST [16][1][1]= 'El Rosario'; CITIESLIST [17] = new Array(); CITIESLIST [17][0] = '5'; CITIESLIST [17][1]= new Array(); CITIESLIST [17][1][0]= '105'; CITIESLIST [17][1][1]= 'El Vergel'; CITIESLIST [17][2]= new Array(); CITIESLIST [17][2][0]= '106'; CITIESLIST [17][2][1]= 'Elda'; CITIESLIST [18] = new Array(); CITIESLIST [18][0] = '1'; CITIESLIST [18][1]= new Array(); CITIESLIST [18][1][0]= '7'; CITIESLIST [18][1][1]= 'Elviria'; CITIESLIST [18][2]= new Array(); CITIESLIST [18][2][0]= '30'; CITIESLIST [18][2][1]= 'Estepona & West'; CITIESLIST [18][3]= new Array(); CITIESLIST [18][3][0]= '27'; CITIESLIST [18][3][1]= 'Estepona East'; CITIESLIST [19] = new Array(); CITIESLIST [19][0] = '7'; CITIESLIST [19][1]= new Array(); CITIESLIST [19][1][0]= '122'; CITIESLIST [19][1][1]= 'Eze-sur-mer'; CITIESLIST [20] = new Array(); CITIESLIST [20][0] = '5'; CITIESLIST [20][1]= new Array(); CITIESLIST [20][1][0]= '108'; CITIESLIST [20][1][1]= 'Fanadix'; CITIESLIST [21] = new Array(); CITIESLIST [21][0] = '7'; CITIESLIST [21][1]= new Array(); CITIESLIST [21][1][0]= '74'; CITIESLIST [21][1][1]= 'Frejus'; CITIESLIST [22] = new Array(); CITIESLIST [22][0] = '1'; CITIESLIST [22][1]= new Array(); CITIESLIST [22][1][0]= '40'; CITIESLIST [22][1][1]= 'Fuengirola'; CITIESLIST [23] = new Array(); CITIESLIST [23][0] = '5'; CITIESLIST [23][1]= new Array(); CITIESLIST [23][1][0]= '48'; CITIESLIST [23][1][1]= 'Gandia'; CITIESLIST [24] = new Array(); CITIESLIST [24][0] = '1'; CITIESLIST [24][1]= new Array(); CITIESLIST [24][1][0]= '39'; CITIESLIST [24][1][1]= 'Girona'; CITIESLIST [25] = new Array(); CITIESLIST [25][0] = '7'; CITIESLIST [25][1]= new Array(); CITIESLIST [25][1][0]= '75'; CITIESLIST [25][1][1]= 'Golfe-juan'; CITIESLIST [25][2]= new Array(); CITIESLIST [25][2][0]= '76'; CITIESLIST [25][2][1]= 'Grasse'; CITIESLIST [25][3]= new Array(); CITIESLIST [25][3][0]= '116'; CITIESLIST [25][3][1]= 'Grimaud'; CITIESLIST [25][4]= new Array(); CITIESLIST [25][4][0]= '119'; CITIESLIST [25][4][1]= 'Gujan-mestras'; CITIESLIST [26] = new Array(); CITIESLIST [26][0] = '5'; CITIESLIST [26][1]= new Array(); CITIESLIST [26][1][0]= '58'; CITIESLIST [26][1][1]= 'Jalon '; CITIESLIST [26][2]= new Array(); CITIESLIST [26][2][0]= '41'; CITIESLIST [26][2][1]= 'Javea/Xabia'; CITIESLIST [27] = new Array(); CITIESLIST [27][0] = '7'; CITIESLIST [27][1]= new Array(); CITIESLIST [27][1][0]= '77'; CITIESLIST [27][1][1]= 'Juan Les Pins'; CITIESLIST [27][2]= new Array(); CITIESLIST [27][2][0]= '78'; CITIESLIST [27][2][1]= 'La Colle Sur Loup'; CITIESLIST [28] = new Array(); CITIESLIST [28][0] = '5'; CITIESLIST [28][1]= new Array(); CITIESLIST [28][1][0]= '109'; CITIESLIST [28][1][1]= 'La Fustera'; CITIESLIST [29] = new Array(); CITIESLIST [29][0] = '7'; CITIESLIST [29][1]= new Array(); CITIESLIST [29][1][0]= '79'; CITIESLIST [29][1][1]= 'La Grande Motte'; CITIESLIST [29][2]= new Array(); CITIESLIST [29][2][0]= '113'; CITIESLIST [29][2][1]= 'La Roquette Sur Var'; CITIESLIST [29][3]= new Array(); CITIESLIST [29][3][0]= '117'; CITIESLIST [29][3][1]= 'La Trayas'; CITIESLIST [30] = new Array(); CITIESLIST [30][0] = '1'; CITIESLIST [30][1]= new Array(); CITIESLIST [30][1][0]= '28'; CITIESLIST [30][1][1]= 'La Zagaleta'; CITIESLIST [30][2]= new Array(); CITIESLIST [30][2][0]= '23'; CITIESLIST [30][2][1]= 'Las Chapas'; CITIESLIST [31] = new Array(); CITIESLIST [31][0] = '7'; CITIESLIST [31][1]= new Array(); CITIESLIST [31][1][0]= '80'; CITIESLIST [31][1][1]= 'Le Cannet'; CITIESLIST [31][2]= new Array(); CITIESLIST [31][2][0]= '81'; CITIESLIST [31][2][1]= 'Le Muy'; CITIESLIST [31][3]= new Array(); CITIESLIST [31][3][0]= '124'; CITIESLIST [31][3][1]= 'Le Thoronet'; CITIESLIST [31][4]= new Array(); CITIESLIST [31][4][0]= '118'; CITIESLIST [31][4][1]= 'Les Arcs'; CITIESLIST [32] = new Array(); CITIESLIST [32][0] = '1'; CITIESLIST [32][1]= new Array(); CITIESLIST [32][1][0]= '65'; CITIESLIST [32][1][1]= 'Los Arqueros'; CITIESLIST [32][2]= new Array(); CITIESLIST [32][2][0]= '8'; CITIESLIST [32][2][1]= 'Los Monteros'; CITIESLIST [32][3]= new Array(); CITIESLIST [32][3][0]= '52'; CITIESLIST [32][3][1]= 'Malaga'; CITIESLIST [33] = new Array(); CITIESLIST [33][0] = '7'; CITIESLIST [33][1]= new Array(); CITIESLIST [33][1][0]= '125'; CITIESLIST [33][1][1]= 'Mandelieu'; CITIESLIST [34] = new Array(); CITIESLIST [34][0] = '1'; CITIESLIST [34][1]= new Array(); CITIESLIST [34][1][0]= '9'; CITIESLIST [34][1][1]= 'Manilva'; CITIESLIST [34][2]= new Array(); CITIESLIST [34][2][0]= '1'; CITIESLIST [34][2][1]= 'Marbella Central'; CITIESLIST [35] = new Array(); CITIESLIST [35][0] = '7'; CITIESLIST [35][1]= new Array(); CITIESLIST [35][1][0]= '126'; CITIESLIST [35][1][1]= 'Menton'; CITIESLIST [36] = new Array(); CITIESLIST [36][0] = '1'; CITIESLIST [36][1]= new Array(); CITIESLIST [36][1][0]= '19'; CITIESLIST [36][1][1]= 'Mijas Costa'; CITIESLIST [36][2]= new Array(); CITIESLIST [36][2][0]= '18'; CITIESLIST [36][2][1]= 'Mijas Golf'; CITIESLIST [36][3]= new Array(); CITIESLIST [36][3][0]= '10'; CITIESLIST [36][3][1]= 'Monte Mayor'; CITIESLIST [37] = new Array(); CITIESLIST [37][0] = '5'; CITIESLIST [37][1]= new Array(); CITIESLIST [37][1][0]= '43'; CITIESLIST [37][1][1]= 'Moraira'; CITIESLIST [38] = new Array(); CITIESLIST [38][0] = '7'; CITIESLIST [38][1]= new Array(); CITIESLIST [38][1][0]= '82'; CITIESLIST [38][1][1]= 'Mouans Sartoux'; CITIESLIST [38][2]= new Array(); CITIESLIST [38][2][0]= '83'; CITIESLIST [38][2][1]= 'Mougins'; CITIESLIST [39] = new Array(); CITIESLIST [39][0] = '5'; CITIESLIST [39][1]= new Array(); CITIESLIST [39][1][0]= '46'; CITIESLIST [39][1][1]= 'Murcia'; CITIESLIST [40] = new Array(); CITIESLIST [40][0] = '7'; CITIESLIST [40][1]= new Array(); CITIESLIST [40][1][0]= '84'; CITIESLIST [40][1][1]= 'Nice'; CITIESLIST [41] = new Array(); CITIESLIST [41][0] = '5'; CITIESLIST [41][1]= new Array(); CITIESLIST [41][1][0]= '60'; CITIESLIST [41][1][1]= 'Nucia/Polop'; CITIESLIST [42] = new Array(); CITIESLIST [42][0] = '1'; CITIESLIST [42][1]= new Array(); CITIESLIST [42][1][0]= '11'; CITIESLIST [42][1][1]= 'Nueva Andalucia'; CITIESLIST [43] = new Array(); CITIESLIST [43][0] = '5'; CITIESLIST [43][1]= new Array(); CITIESLIST [43][1][0]= '49'; CITIESLIST [43][1][1]= 'Oliva'; CITIESLIST [43][2]= new Array(); CITIESLIST [43][2][0]= '102'; CITIESLIST [43][2][1]= 'Ondara'; CITIESLIST [44] = new Array(); CITIESLIST [44][0] = '7'; CITIESLIST [44][1]= new Array(); CITIESLIST [44][1][0]= '85'; CITIESLIST [44][1][1]= 'Opio'; CITIESLIST [45] = new Array(); CITIESLIST [45][0] = '5'; CITIESLIST [45][1]= new Array(); CITIESLIST [45][1][0]= '110'; CITIESLIST [45][1][1]= 'Orihuela'; CITIESLIST [45][2]= new Array(); CITIESLIST [45][2][0]= '103'; CITIESLIST [45][2][1]= 'Pedreguer'; CITIESLIST [45][3]= new Array(); CITIESLIST [45][3][0]= '107'; CITIESLIST [45][3][1]= 'Pego'; CITIESLIST [46] = new Array(); CITIESLIST [46][0] = '7'; CITIESLIST [46][1]= new Array(); CITIESLIST [46][1][0]= '86'; CITIESLIST [46][1][1]= 'Peymeinade'; CITIESLIST [46][2]= new Array(); CITIESLIST [46][2][0]= '121'; CITIESLIST [46][2][1]= 'Pierrefeu'; CITIESLIST [46][3]= new Array(); CITIESLIST [46][3][0]= '87'; CITIESLIST [46][3][1]= 'Plascassier'; CITIESLIST [47] = new Array(); CITIESLIST [47][0] = '1'; CITIESLIST [47][1]= new Array(); CITIESLIST [47][1][0]= '13'; CITIESLIST [47][1][1]= 'Puerto Banus'; CITIESLIST [47][2]= new Array(); CITIESLIST [47][2][0]= '25'; CITIESLIST [47][2][1]= 'Rio Real'; CITIESLIST [47][3]= new Array(); CITIESLIST [47][3][0]= '20'; CITIESLIST [47][3][1]= 'Riviera'; CITIESLIST [48] = new Array(); CITIESLIST [48][0] = '7'; CITIESLIST [48][1]= new Array(); CITIESLIST [48][1][0]= '88'; CITIESLIST [48][1][1]= 'Roquebrune-cap-martin'; CITIESLIST [48][2]= new Array(); CITIESLIST [48][2][0]= '89'; CITIESLIST [48][2][1]= 'Rouqefort Les Pins'; CITIESLIST [48][3]= new Array(); CITIESLIST [48][3][0]= '90'; CITIESLIST [48][3][1]= 'Saint Paul De Vence '; CITIESLIST [48][4]= new Array(); CITIESLIST [48][4][0]= '91'; CITIESLIST [48][4][1]= 'Sainte Maxime'; CITIESLIST [49] = new Array(); CITIESLIST [49][0] = '1'; CITIESLIST [49][1]= new Array(); CITIESLIST [49][1][0]= '2'; CITIESLIST [49][1][1]= 'San Pedro'; CITIESLIST [50] = new Array(); CITIESLIST [50][0] = '5'; CITIESLIST [50][1]= new Array(); CITIESLIST [50][1][0]= '123'; CITIESLIST [50][1][1]= 'Santa Pola'; CITIESLIST [50][2]= new Array(); CITIESLIST [50][2][0]= '104'; CITIESLIST [50][2][1]= 'Sax'; CITIESLIST [51] = new Array(); CITIESLIST [51][0] = '7'; CITIESLIST [51][1]= new Array(); CITIESLIST [51][1][0]= '112'; CITIESLIST [51][1][1]= 'Seillans'; CITIESLIST [52] = new Array(); CITIESLIST [52][0] = '1'; CITIESLIST [52][1]= new Array(); CITIESLIST [52][1][0]= '26'; CITIESLIST [52][1][1]= 'Sierra Blanca'; CITIESLIST [52][2]= new Array(); CITIESLIST [52][2][0]= '38'; CITIESLIST [52][2][1]= 'Sotogrande'; CITIESLIST [53] = new Array(); CITIESLIST [53][0] = '7'; CITIESLIST [53][1]= new Array(); CITIESLIST [53][1][0]= '114'; CITIESLIST [53][1][1]= 'Speracedes'; CITIESLIST [53][2]= new Array(); CITIESLIST [53][2][0]= '92'; CITIESLIST [53][2][1]= 'St Jeanette'; CITIESLIST [53][3]= new Array(); CITIESLIST [53][3][0]= '93'; CITIESLIST [53][3][1]= 'St Raphael'; CITIESLIST [53][4]= new Array(); CITIESLIST [53][4][0]= '94'; CITIESLIST [53][4][1]= 'St Tropez'; CITIESLIST [54] = new Array(); CITIESLIST [54][0] = '5'; CITIESLIST [54][1]= new Array(); CITIESLIST [54][1][0]= '57'; CITIESLIST [54][1][1]= 'Teulada'; CITIESLIST [55] = new Array(); CITIESLIST [55][0] = '1'; CITIESLIST [55][1]= new Array(); CITIESLIST [55][1][0]= '32'; CITIESLIST [55][1][1]= 'Torremolinos'; CITIESLIST [56] = new Array(); CITIESLIST [56][0] = '5'; CITIESLIST [56][1]= new Array(); CITIESLIST [56][1][0]= '62'; CITIESLIST [56][1][1]= 'Torrevieja'; CITIESLIST [57] = new Array(); CITIESLIST [57][0] = '7'; CITIESLIST [57][1]= new Array(); CITIESLIST [57][1][0]= '120'; CITIESLIST [57][1][1]= 'Tourrettes Sur Loup'; CITIESLIST [57][2]= new Array(); CITIESLIST [57][2][0]= '95'; CITIESLIST [57][2][1]= 'Valbonne'; CITIESLIST [58] = new Array(); CITIESLIST [58][0] = '1'; CITIESLIST [58][1]= new Array(); CITIESLIST [58][1][0]= '53'; CITIESLIST [58][1][1]= 'Velez Malaga'; CITIESLIST [59] = new Array(); CITIESLIST [59][0] = '7'; CITIESLIST [59][1]= new Array(); CITIESLIST [59][1][0]= '96'; CITIESLIST [59][1][1]= 'Vence'; CITIESLIST [59][2]= new Array(); CITIESLIST [59][2][0]= '97'; CITIESLIST [59][2][1]= 'Vidauban'; CITIESLIST [60] = new Array(); CITIESLIST [60][0] = '5'; CITIESLIST [60][1]= new Array(); CITIESLIST [60][1][0]= '61'; CITIESLIST [60][1][1]= 'Villajoyosa'; CITIESLIST [61] = new Array(); CITIESLIST [61][0] = '7'; CITIESLIST [61][1]= new Array(); CITIESLIST [61][1][0]= '98'; CITIESLIST [61][1][1]= 'Villefranche Sur Mer'; CITIESLIST [61][2]= new Array(); CITIESLIST [61][2][0]= '99'; CITIESLIST [61][2][1]= 'Villeneuve Loubet';var CS_CITIESLIST = CITIESLIST;CITIESLIST = null;</SCRIPT>
<SCRIPT language="JavaScript">
<!--

function WA_UnloadList(thelist,leavevals,bottomnum)    {
  while (thelist.options.length != leavevals+bottomnum)     {
      thelist.options[leavevals] = null;
  }
  return leavevals;
}

function WA_FilterAndPopulateSubList(thearray,sourceselect,targetselect,leaveval,bottomleave,usesource,delimiter)     {
  startid = WA_UnloadList(targetselect,1,0);
  mainids = new Array();
  if (usesource)    maintext = new Array();
  for (var j=0; j<sourceselect.options.length; j++)     {
    if (sourceselect.options[j].selected)     {
      mainids[mainids.length] = sourceselect.options[j].value;
      if (usesource)     maintext[maintext.length] = sourceselect.options[j].text + delimiter;
    }
  }
  for (var i=0; i<thearray.length; i++)     {
    goodid = false;
    for (var h=0; h<mainids.length; h++)     {
        if (thearray[i][0] == mainids[h])     {
          goodid = true;
            break;
        }      
      }
    if (goodid)     {
      theBox = targetselect;
      theLength = parseInt(theBox.options.length);
      theServices = thearray[i].length + startid;
      var l=1;
      for (var k=startid; k<theServices; k++)     {
        if (l == thearray[i].length)     break;
        theBox.options[k] = new Option();
        theBox.options[k].value = thearray[i][l][0];
        if (usesource)              theBox.options[k].text = thearray[i][l][1];
            else                  theBox.options[k].text = thearray[i][l][1];
        l++;
      }
        startid = k;
      }
  }
}

//-->
</SCRIPT>
0
 
LVL 3

Expert Comment

by:zastil
Comment Utility
Check it by looking here when drilling down countries

http://www.macanthonyrealtyproperties.com/properties/search.asp
0
 
LVL 10

Expert Comment

by:Shailesh15
Comment Utility
Try this... It's not tested against database though!



<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%Option Explicit%>
<%Response.Buffer = True%>
<html>
<head>
<title>Menu Prueba</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; color: #993333; }
-->
</style>
</head>
<%

 

Dim strDataPath, strConnectString, objConnection
Dim strSistema, strEquipo, strElemento, objRS, strSelected, strSQL

 

strSistema = Request.Form("Sistema")
strEquipo = Request.Form("Equipo")
strElemento = Request.Form("Elemento")
src= = Request.Form("cmbsrc")

select case src
case "1"
     strEquipo=""
     strElemento =""
case "2"
     strElemento =""
end select
 

'set connection strings for entire application

 

strDataPath = Server.MapPath("analisis.mdb")
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;"_
            + " Data Source= " & strDataPath & ";"
           
       
If Not IsObject("ojbConnection") Then
    Set objConnection=Server.CreateObject("ADODB.Connection")
    objConnection.ConnectionTimeout = 15
    objConnection.CommandTimeout = 10
    objConnection.Mode = 3 'adModeReadWrite
    If objConnection.state = 0 Then
        objConnection.Open strConnectString
    End If
End If

 

%>

 

<%

 

Sub makeSistema()

 

    If Not IsObject("objRS") Then
        Set objRS=Server.CreateObject("ADODB.RecordSet")
    End If
    If objRS.state <> 0 Then
        objRS.close
    End If
    strSQL = "SELECT Sis_Codi FROM Sistemas"
    objRS.Open strSQL,objConnection,3,3
    Response.Write("<option></option>" & vbCrLf )
    Do While Not objRS.EOF

 

        If objRS("Sis_Codi") = strSistema Then
            strSelected = " Selected "
        Else
            strSelected = ""
        End If

 

        Response.Write("<option" & strSelected & ">" &_
                 objRS("Sis_Codi") & "</option>" & vbCrLf )
        objRS.MoveNext

 

    Loop

 

    objRS.Close
    Set objRS=Nothing
End Sub
%>
<%

 

Sub makeEquipo()
    If strSistema <> "" Then
        If Not IsObject("objRS") Then
            Set objRS=Server.CreateObject("ADODB.RecordSet")
        End If

 

        If objRS.state <> 0 Then
            objRS.close
        End If

 

        strSQL ="SELECT Equ_Codi FROM Equipos "
        if(strSistema<>"") then strsQl= strsql & " WHERE Sis_Codi = '" &  strSistema & "'"
        strsql =strsql &  " ORDER BY Equ_Codi"
       
        objRS.Open strSQL,objConnection,3,3

 

        If objRS.eof Then
            Response.Write("<option>No Se Encontraron Equipos</option>")
        Else
            Response.Write("<option>Seleccione un Equipo Ahora</option>" & vbCrLf )

 

            Do While Not objRS.EOF
                If objRS("Equ_Codi") = strEquipo Then
                    strSelected = " Selected "
                Else
                   strSelected = ""
                End If

 

                Response.Write("<option" & strSelected & ">" &_
                         objRS("Equ_Codi") & "</option>" & vbCrLf )
                objRS.MoveNext

 

            Loop

 

        End If
        objRS.Close
        Set objRS=Nothing

 

    Else
        Response.Write("<option>Seleccione un Equipo Primero </option>")
    End If

 

End Sub

 

Sub makeElemento()
    If strEquipo <> "Seleccione un Sistema Primero" And _
     strEquipo <> "Seleccione un Elemento Ahora" And strEquipo <>"" Then
        If Not IsObject("objRS") Then
            Set objRS=Server.CreateObject("ADODB.RecordSet")
        End If

 

        If objRS.state <> 0 Then
            objRS.close
        End If

 
            
        strSQL = "SELECT Equ_Desc FROM Equipos "
        if(strEquipo<>"") then  strsql =strsql &  " WHERE Equ_Codi = '" & strEquipo & "'"
        strsql =strsql & "  ORDER BY Equ_Codi"
       
        objRS.Open strSQL,objConnection,3,3

 

        If objRS.eof Then
            Response.Write("<option>No Descriptions Found</option>")
        Else

 

            Response.Write("<option>Select Description Now</option>" & vbCrLf )
            Do While Not objRS.EOF
                If objRS("Equ_Desc") = strElemento Then
                    strSelected = " Selected "
                Else
                    strSelected = ""
                End If
                Response.Write("<option" & strSelected & ">" &_
                         objRS("Equ_Desc") & "</option>" & vbCrLf )
                objRS.MoveNext
            Loop

 

        End If
        objRS.Close
        Set objRS=Nothing

 

    Else
        Response.Write("<option>Select a Region First</option>")
    End If

 

End Sub
%>

 

<SCRIPT LANGUAGE=javascript>
<!--
Function submitSistema(){
    var objForm = document.forms[0];
    objForm.elements['Equipo'].selectedIndex=0;
    objForm.elements['Elemento'].selectedIndex = 0;
    document.theform.cmbsrc.value= 1;
    objForm.submit();

 

}

 

Function submitEquipo(){
    var objForm = document.forms[0];
    objForm.elements['Elemento'].selectedIndex = 0;
    document.theform.cmbsrc.value= 2;
    objForm.submit();

 

}
//-->
</SCRIPT>

 

<SCRIPT LANGUAGE=javascript>

 

<!--

 

Function submitForm(){

 

    var objForm = document.forms[0];

 

    objForm.action = "http://localhost/mantenimiento/Test/menustest.asp"

 

    return true;

 

}

 

//-->

 

</SCRIPT>
<body>
<FORM action="" method=POST id=form1 name=form1 onSubmit="return submitForm()">
<input type="hidden" value="1" name="cmbsrc">
  <table width="80%"  border="0">
    <tr>
      <td width="44%"><span class="style3">Sistema</span></td>
      <td width="56%"><select name="Sistema" onChange="submitSistema()">
        <%call makeSistema%>
      </select>
      <input type="submit" value="OK" id=submit12 name=submit1></td>
    </tr>
    <tr>
      <td><span class="style3">Equipos</span></td>
      <td><select name="Equipo" onChange="submitEquipo()">
        <%call makeEquipo%>
      </select>
      <input type="submit" value="OK" id=submit1 name=submit12></td>
    </tr>
    <tr>
      <td><span class="style3">Elementos a Gr&aacute;ficar </span></td>
      <td><select name="Elemento">
        <%call makeElemento%>
      </select>
      <input type="submit" value="OK" id=submit13 name=submit13></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</FORM>

 

</BODY>

 

<%
objConnection.Close
Set objConnection = Nothing
%>
</html>

0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
YOu don't need to have the submit buttons--the onChange() event of the select takes care of that. Please re-read my code:

<%@ Language = VBScript %>
<%Option Explicit%>
<%Response.Buffer = True%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<%
dim  strDataPath, strConnectString, objConnection, strCountry, strRegion, strCity, objRS, strSelected

strCountry = Request.Form("Country")
strRegion = Request.Form("Region")
strCity = Request.Form("City")


'set connection strings for entire application
strDataPath = server.MapPath("NorthWind.mdb")
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;"_
                  + " Data Source= " & strDataPath & ";"_
                  + " Mode=Share Deny None;User Id=admin;PASSWORD=;"
                  
if not IsObject("ojbConnection") then
      set objConnection=Server.CreateObject("ADODB.Connection")
      objConnection.ConnectionTimeout = 15
      objConnection.CommandTimeout =  10
      objConnection.Mode = 3 'adModeReadWrite
      if objConnection.state = 0 then
            objConnection.Open strConnectString
      end if
end if

sub makeCountry()
      if not isObject("objRS") then
            set objRS=Server.CreateObject("ADODB.RecordSet")
      end if
      if objRS.state <> 0 then
            objRS.close
      end if
      objRS.Open "SELECT DISTINCT Country  FROM Customers ORDER BY Country",objConnection,3,3
      Response.Write("<option></option>" & VBCRLF )
      do while not objRS.EOF
            if objRS("Country") = strCountry then
                  strSelected = " Selected "
            else
                  strSelected = ""
            end if
            Response.Write("<option" & strSelected & ">" & objRS("Country") & "</option>" & VBCRLF )
            objRS.MoveNext
      loop
      objRS.Close
      set objRS=Nothing
end sub

sub makeRegion()
      if strCountry <> "" then
            if not isObject("objRS") then
                  set objRS=Server.CreateObject("ADODB.RecordSet")
            end if
            if objRS.state <> 0 then
                  objRS.close
            end if
            objRS.Open "SELECT DISTINCT Region FROM Customers WHERE Country = '" & strCountry & "' ORDER BY Region",objConnection,3,3
            if objRS.eof then
                  Response.Write("<option>No Regions Found</option>")
            else
                  Response.Write("<option>Select Region Now</option>" & VBCRLF )
                  do while not objRS.EOF
                        if objRS("Region") = strRegion then
                              strSelected = " Selected "
                        else
                              strSelected = ""
                        end if
                        Response.Write("<option" & strSelected & ">" & objRS("Region") & "</option>" & VBCRLF )
                        objRS.MoveNext
                  loop
            end if
            objRS.Close
            set objRS=Nothing
      else
            Response.Write("<option>Select a Country First</option>")
      end if
end sub

sub makeCity()
      if strRegion <> "Select a Country First" AND  strRegion <> "Select Region Now" AND strRegion <>"" then
            if not isObject("objRS") then
                  set objRS=Server.CreateObject("ADODB.RecordSet")
            end if
            if objRS.state <> 0 then
                  objRS.close
            end if
            objRS.Open "SELECT DISTINCT City FROM Customers WHERE Region = '" & strRegion & "' ORDER BY City",objConnection,3,3
            if objRS.eof then
                  Response.Write("<option>No Cities Found</option>")
            else
                  Response.Write("<option>Select City Now</option>" & VBCRLF )
                  do while not objRS.EOF
                        if objRS("City") = strCity then
                              strSelected = " Selected "
                        else
                              strSelected = ""
                        end if
                        Response.Write("<option" & strSelected & ">" & objRS("City") & "</option>" & VBCRLF )
                        objRS.MoveNext
                  loop
            end if
            objRS.Close
            set objRS=Nothing
      else
            Response.Write("<option>Select a Region First</option>")
      end if
end sub
%>

<SCRIPT LANGUAGE=javascript>
<!--

function submitCountry(){
      var objForm = document.forms[0];
      objForm.elements['Region'].selectedIndex=0;
      objForm.elements['City'].selectedIndex = 0;
      objForm.submit();
}
function submitRegion(){
      var objForm = document.forms[0];
      objForm.elements['City'].selectedIndex = 0;
      objForm.submit();
}

function submitForm(){
      var objForm = document.forms[0];
      objForm.action = "http://www.FairfieldConsulting.com/processform.asp"
      return true;
}
//-->
</SCRIPT>

</HEAD>
<BODY>
<FORM action="" method=POST id=form1 name=form1 onSubmit="return submitForm()">
<SELECT  name="Country" onChange="submitCountry()">
      <%call  makeCountry%>
</SELECT><br>
<SELECT  name="Region" onChange="submitRegion()">
      <%call makeRegion%>
</SELECT><br>
<SELECT  name="City">
      <%call makeCity%>
</SELECT><br>

<p><INPUT type="submit" value="Submit" id=submit1 name=submit1></p>
</FORM>
</BODY>
<%
objConnection.Close
set objConnection = Nothing
%>

</HTML>


FtB
0
 

Author Comment

by:pilarvalsala
Comment Utility
Hi Fritz_the_blank

I´ve tried, your code, but the menus don´t change until I click the submit button
0
 
LVL 10

Expert Comment

by:Shailesh15
Comment Utility
Make sure that you are actually changing the selection. Not just clicking the combo box.

For example
if you have 3 choices Choice1,Choice2,Choice3. Combo box is SHOWING Choice1.
If you click on combo box & select choice1 again. Event will not fire & form is not submitted.
If you click on combo box & select any other choice. Event WILL fire & form WILL get submitted.

The code I posted above, also handles combo loading logic (selection) & reset of combo boxes when user changes first combo box  after navigating to third combo.
0
 

Author Comment

by:pilarvalsala
Comment Utility
Shailesh15

I´m getting an error, where do I define the form "cmbsrc"

sintaxis error
/mantenimiento/Test/menustest2.asp, line 20, column 5
src= = Request.Form("cmbsrc")
----^
0
 
LVL 10

Expert Comment

by:Shailesh15
Comment Utility
change
src= = Request.Form("cmbsrc")
to
src = Request.Form("cmbsrc")

there is a extra =.
cmbsrc is a hidden field just below form tag
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:pilarvalsala
Comment Utility
This is what I have, but still I have to click the ok to change the other menues, plus now the third one is not showing up

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%Option Explicit%>
<%Response.Buffer = True%>
<html>
<head>
<title>Menu Prueba</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; color: #993333; }
-->
</style>
</head>
<%
Dim strDataPath, strConnectString, objConnection
Dim strSistema, strEquipo, strElemento, objRS, strSelected, strSQL, src
strSistema = Request.Form("Sistema")
strEquipo = Request.Form("Equipo")
strElemento = Request.Form("Elemento")
src = Request.Form("cmbsrc")
select case src
case "1"
     strEquipo=""
     strElemento =""
case "2"
     strElemento =""
end select
 'set connection strings for entire application

 strDataPath = Server.MapPath("analisis.mdb")
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;"_
            + " Data Source= " & strDataPath & ";"        
   
If Not IsObject("ojbConnection") Then
    Set objConnection=Server.CreateObject("ADODB.Connection")
    objConnection.ConnectionTimeout = 15
    objConnection.CommandTimeout = 10
    objConnection.Mode = 3 'adModeReadWrite
    If objConnection.state = 0 Then
        objConnection.Open strConnectString
    End If
End If
%>

<%
Sub makeSistema()
    If Not IsObject("objRS") Then
        Set objRS=Server.CreateObject("ADODB.RecordSet")
    End If
    If objRS.state <> 0 Then
        objRS.close
    End If
    strSQL = "SELECT Sis_Codi FROM Sistemas"
    objRS.Open strSQL,objConnection,3,3
    Response.Write("<option></option>" & vbCrLf )
    Do While Not objRS.EOF
        If objRS("Sis_Codi") = strSistema Then
            strSelected = " Selected "
        Else
            strSelected = ""
        End If
        Response.Write("<option" & strSelected & ">" &_
                 objRS("Sis_Codi") & "</option>" & vbCrLf )
        objRS.MoveNext
    Loop
    objRS.Close
    Set objRS=Nothing
End Sub
%>
<%
Sub makeEquipo()
    If strSistema <> "" Then
        If Not IsObject("objRS") Then
            Set objRS=Server.CreateObject("ADODB.RecordSet")
        End If
        If objRS.state <> 0 Then
            objRS.close
        End If
        strSQL ="SELECT Equ_Codi FROM Equipos "
        if(strSistema<>"") then strsQl= strsql & " WHERE Sis_Codi = '" &  strSistema & "'"
        strsql =strsql &  " ORDER BY Equ_Codi"
        objRS.Open strSQL,objConnection,3,3
        If objRS.eof Then
            Response.Write("<option>No Se Encontraron Equipos</option>")
        Else
            Response.Write("<option>Seleccione un Equipo Ahora</option>" & vbCrLf )

             Do While Not objRS.EOF
                If objRS("Equ_Codi") = strEquipo Then
                    strSelected = " Selected "
                Else
                   strSelected = ""
                End If
                Response.Write("<option" & strSelected & ">" &_
                         objRS("Equ_Codi") & "</option>" & vbCrLf )
                objRS.MoveNext

             Loop

         End If
        objRS.Close
        Set objRS=Nothing
    Else
        Response.Write("<option>Seleccione un Equipo Primero </option>")
    End If
End Sub

Sub makeElemento()
    If strEquipo <> "Seleccione un Sistema Primero" And _
     strEquipo <> "Seleccione un Elemento Ahora" And strEquipo <>"" Then
        If Not IsObject("objRS") Then
            Set objRS=Server.CreateObject("ADODB.RecordSet")
        End If
        If objRS.state <> 0 Then
            objRS.close
        End If      
        strSQL = "SELECT Equ_Desc FROM Equipos "
        if(strEquipo<>"") then  strsql =strsql &  " WHERE Equ_Codi = '" & strEquipo & "'"
        strsql =strsql & "  ORDER BY Equ_Codi"  
        objRS.Open strSQL,objConnection,3,3
        If objRS.eof Then
            Response.Write("<option>No Descriptions Found</option>")
        Else
            Response.Write("<option>Select Description Now</option>" & vbCrLf )
            Do While Not objRS.EOF
                If objRS("Equ_Desc") = strElemento Then
                    strSelected = " Selected "
                Else
                    strSelected = ""
                End If
                Response.Write("<option" & strSelected & ">" &_
                         objRS("Equ_Desc") & "</option>" & vbCrLf )
                objRS.MoveNext
            Loop
        End If
        objRS.Close
        Set objRS=Nothing

     Else
        Response.Write("<option>Select a Region First</option>")
    End If

End Sub
%>

 <SCRIPT LANGUAGE=javascript>
<!--
Function submitSistema(){
    var objForm = document.forms[0];
    objForm.elements['Equipo'].selectedIndex=0;
    objForm.elements['Elemento'].selectedIndex = 0;
    document.theform.cmbsrc.value= 1;
    objForm.submit();
}
Function submitEquipo(){
    var objForm = document.forms[0];
    objForm.elements['Elemento'].selectedIndex = 0;
    document.theform.cmbsrc.value= 2;
    objForm.submit();
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE=javascript>
<!--
Function submitForm(){
    var objForm = document.forms[0];
    objForm.action = "http://localhost/mantenimiento/Test/menustest.asp"
    return true;
}
//-->
</SCRIPT>
<body>
<FORM action="" method=POST id=form1 name=form1 onSubmit="return submitForm()">
<input type="hidden" value="1" name="cmbsrc">
  <table width="80%"  border="0">
    <tr>
      <td width="44%"><span class="style3">Sistema</span></td>
      <td width="56%"><select name="Sistema" onChange="submitSistema()">
        <%call makeSistema%>
      </select>
      </td>
    </tr>
    <tr>
      <td><span class="style3">Equipos</span></td>
      <td><select name="Equipo" onChange="submitEquipo()">
        <%call makeEquipo%>
      </select>
      </td>
    </tr>
    <tr>
      <td><span class="style3">Elementos a Gr&aacute;ficar </span></td>
      <td><select name="Elemento">
        <%call makeElemento%>
      </select>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" value="OK" id=submit13 name=submit13></td>
    </tr>
  </table>
</FORM>
</BODY>
<%
objConnection.Close
Set objConnection = Nothing
%>
</html>
0
 
LVL 10

Expert Comment

by:Shailesh15
Comment Utility
Try this..  I not not sure about 3rd combobox though.
Are you sure it has nothing to do with your check
"   If strEquipo <> "Seleccione un Sistema Primero" And _
     strEquipo <> "Seleccione un Elemento Ahora" And strEquipo <>"" Then" ?.

************************************
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%Option Explicit%>
<%Response.Buffer = True%>
<html>
<head>
<title>Menu Prueba</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; color: #993333; }
-->
</style>
</head>
<%
Dim strDataPath, strConnectString, objConnection
Dim strSistema, strEquipo, strElemento, objRS, strSelected, strSQL, src
strSistema = Request.Form("Sistema")
strEquipo = Request.Form("Equipo")
strElemento = Request.Form("Elemento")
src = Request.Form("cmbsrc")
select case src
case "1"
     strEquipo=""
     strElemento =""
case "2"
     strElemento =""
end select
 'set connection strings for entire application

 strDataPath = Server.MapPath("analisis.mdb")
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;"_
            + " Data Source= " & strDataPath & ";"        
   
If Not IsObject("ojbConnection") Then
    Set objConnection=Server.CreateObject("ADODB.Connection")
    objConnection.ConnectionTimeout = 15
    objConnection.CommandTimeout = 10
    objConnection.Mode = 3 'adModeReadWrite
    If objConnection.state = 0 Then
        objConnection.Open strConnectString
    End If
End If
%>

<%
Sub makeSistema()
    If Not IsObject("objRS") Then
        Set objRS=Server.CreateObject("ADODB.RecordSet")
    End If
    If objRS.state <> 0 Then
        objRS.close
    End If
    strSQL = "SELECT Sis_Codi FROM Sistemas"
    objRS.Open strSQL,objConnection,3,3
    Response.Write("<option></option>" & vbCrLf )
    Do While Not objRS.EOF
        If objRS("Sis_Codi") = strSistema Then
            strSelected = " Selected "
        Else
            strSelected = ""
        End If
        Response.Write("<option" & strSelected & ">" &_
                 objRS("Sis_Codi") & "</option>" & vbCrLf )
        objRS.MoveNext
    Loop
    objRS.Close
    Set objRS=Nothing
End Sub
%>
<%
Sub makeEquipo()
    If strSistema <> "" Then
        If Not IsObject("objRS") Then
            Set objRS=Server.CreateObject("ADODB.RecordSet")
        End If
        If objRS.state <> 0 Then
            objRS.close
        End If
        strSQL ="SELECT Equ_Codi FROM Equipos "
        if(strSistema<>"") then strsQl= strsql & " WHERE Sis_Codi = '" &  strSistema & "'"
        strsql =strsql &  " ORDER BY Equ_Codi"
        objRS.Open strSQL,objConnection,3,3
        If objRS.eof Then
            Response.Write("<option>No Se Encontraron Equipos</option>")
        Else
            Response.Write("<option>Seleccione un Equipo Ahora</option>" & vbCrLf )

             Do While Not objRS.EOF
                If objRS("Equ_Codi") = strEquipo Then
                    strSelected = " Selected "
                Else
                   strSelected = ""
                End If
                Response.Write("<option" & strSelected & ">" &_
                         objRS("Equ_Codi") & "</option>" & vbCrLf )
                objRS.MoveNext

             Loop

         End If
        objRS.Close
        Set objRS=Nothing
    Else
        Response.Write("<option>Seleccione un Equipo Primero </option>")
    End If
End Sub

Sub makeElemento()
    If strEquipo <> "Seleccione un Sistema Primero" And _
     strEquipo <> "Seleccione un Elemento Ahora" And strEquipo <>"" Then
        If Not IsObject("objRS") Then
            Set objRS=Server.CreateObject("ADODB.RecordSet")
        End If
        If objRS.state <> 0 Then
            objRS.close
        End If      
        strSQL = "SELECT Equ_Desc FROM Equipos "
        if(strEquipo<>"") then  strsql =strsql &  " WHERE Equ_Codi = '" & strEquipo & "'"
        strsql =strsql & "  ORDER BY Equ_Codi"  
        objRS.Open strSQL,objConnection,3,3
        If objRS.eof Then
            Response.Write("<option>No Descriptions Found</option>")
        Else
            Response.Write("<option>Select Description Now</option>" & vbCrLf )
            Do While Not objRS.EOF
                If objRS("Equ_Desc") = strElemento Then
                    strSelected = " Selected "
                Else
                    strSelected = ""
                End If
                Response.Write("<option" & strSelected & ">" &_
                         objRS("Equ_Desc") & "</option>" & vbCrLf )
                objRS.MoveNext
            Loop
        End If
        objRS.Close
        Set objRS=Nothing

     Else
        Response.Write("<option>Select a Region First</option>")
    End If

End Sub
%>

 <SCRIPT LANGUAGE=javascript>
<!--
Function submitSistema(){
    //var objForm = document.forms[0];
    //objForm.elements['Equipo'].selectedIndex=0;
    //objForm.elements['Elemento'].selectedIndex = 0;
    document.form1.cmbsrc.value= 1;
   document.form1.submit();
}
Function submitEquipo(){
    //var objForm = document.forms[0];
    //objForm.elements['Elemento'].selectedIndex = 0;
    document.form1.cmbsrc.value= 2;
    document.form1.submit();
}
//-->
</SCRIPT>

<body>
<FORM action="http://localhost/mantenimiento/Test/menustest.asp" method=POST id=form1 name=form1>
<input type="hidden" value="1" name="cmbsrc">
  <table width="80%"  border="0">
    <tr>
      <td width="44%"><span class="style3">Sistema</span></td>
      <td width="56%"><select name="Sistema" onChange="submitSistema()">
        <%call makeSistema%>
      </select>
      </td>
    </tr>
    <tr>
      <td><span class="style3">Equipos</span></td>
      <td><select name="Equipo" onChange="submitEquipo()">
        <%call makeEquipo%>
      </select>
      </td>
    </tr>
    <tr>
      <td><span class="style3">Elementos a Gr&aacute;ficar </span></td>
      <td><select name="Elemento">
        <%call makeElemento%>
      </select>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" value="OK" id=submit13 name=submit13></td>
    </tr>
  </table>
</FORM>
</BODY>
<%
objConnection.Close
Set objConnection = Nothing
%>
</html>
0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
Please run your page, go to the view menu and select source, and then paste the source here. Once you do that, I should be able to figure out what the issue is.

I have used this code in many places without problem.

Fritz the Blank
0
 

Author Comment

by:pilarvalsala
Comment Utility
Fritz_the_blank

here is it

<html>
<head>
<title>Menu Prueba</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; color: #993333; }
-->
</style>
</head>


<SCRIPT LANGUAGE=javascript>
<!--
Function submitSistema(){
    var objForm = document.forms[0];
    objForm.elements['Equipo'].selectedIndex=0;
    objForm.elements['Elemento'].selectedIndex = 0;
    objForm.submit();

}

Function submitEquipo(){
    var objForm = document.forms[0];
    objForm.elements['Elemento'].selectedIndex = 0;
    objForm.submit();

}
//-->
</SCRIPT>

<SCRIPT LANGUAGE=javascript>

<!--

Function submitForm(){

    var objForm = document.forms[0];

    objForm.action = "http://localhost/mantenimiento/Test/menustest.asp"

    return true;

}

//-->

</SCRIPT>
<body>
<FORM action="" method=POST id=form1 name=form1 onSubmit="return submitForm()">
  <table width="80%"  border="0">
    <tr>
      <td width="44%"><span class="style3">Sistema</span></td>
      <td width="56%"><select name="Sistema" onChange="submitSistema()">
        <option></option>
<option>BOMBEO</option>
<option>COMPRESION</option>
<option>CONTRAINCENDIO</option>
<option>GENERACION</option>
<option>POZOS</option>
<option>SERVICIOS</option>

      </select>      </td>
    </tr>
    <tr>
      <td><span class="style3">Equipos</span></td>
      <td><select name="Equipo" onChange="submitEquipo()">
        <option>Seleccione un Equipo Primero </option>
      </select>      </td>
    </tr>
    <tr>
      <td><span class="style3">Elementos a Gr&aacute;ficar </span></td>
      <td><select name="Elemento">
        <option>Select a Region First</option>
      </select>      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" value="OK" id=submit132 name=submit13></td>
    </tr>
  </table>
</FORM>

</BODY>


</html>

0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
Okay I found the first issue: unlike VBScript, JavaScript is case sensitive, so you must write function rather than Function:

<SCRIPT LANGUAGE=javascript>
<!--
function submitSistema(){
    var objForm = document.forms[0];
    objForm.elements['Equipo'].selectedIndex=0;
    objForm.elements['Elemento'].selectedIndex = 0;
    objForm.submit();

}

function submitEquipo(){
    var objForm = document.forms[0];
    objForm.elements['Elemento'].selectedIndex = 0;
    objForm.submit();

}
//-->
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 500 total points
Comment Utility
Here also:

<!--

function submitForm(){
    var objForm = document.forms[0];
    objForm.action = "http://localhost/mantenimiento/Test/menustest.asp"
    return true;
}


Fritz the Blank
0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
So please make those few changes and then try the code please.

FtB
0
 

Author Comment

by:pilarvalsala
Comment Utility
Thank you FtB, accepting the question will give you the points?

Thank you so much and sorry again for the other time...

Thank you to Shailesh15 too
0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
Fair enough. Please remember that we all volunteer time here without compensation. The only thing that we get back is the gratitude of those asking the questions, so closing out your questions is the right thing to do.

If you feel that others have been helpful, you can post separate questions with the title "Points for Shailesh15" and etc. to show your appreciation.

Good luck with the project.

Fritz the Blank
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now