Results 1 to 3 of 3

Thread: ASP page, need script for dropdowns

  1. #1
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ASP page, need script for dropdowns

    Hi,

    I am very new to coding websites (infact this in my first one)

    I wrote this code for the website with a query to a postgreSQL database.
    The queries works fine and are able to get data into my dropdown boxes. However I want to populate my second dropdown box according to the selection the user made in the first dropdown and so on with the rest of the dropdowns.

    Code:
    <%@ Language=VBScript %>
    <!-- #include file="DB/adodbinc.asp" -->
    <%Response.expires=0%>
    <%response.buffer=true%>
    <%
    
    DIM SQLstr
    DIM arrprovince
    DIM arrcity
    DIM arrcountry
    DIM numcityRows
    DIM numprovinceRows 
    DIM numcountryRows
    DIM i    
    
    
       SQLstr =  "SELECT DISTINCT country FROM hotspot WHERE country<>'Null' AND country<>'South Africa' AND country<>'Switzerland (CH)'"
        
        arrcountry = DB_Query(strConnection,SQLstr,dbrt_GetRowsArray)
      
     IF IsArray(arrcountry) THEN
      numcountryRows = Ubound(arrcountry,gr_rows)
     ELSE
      numcountryRows = -1 
     END IF
        
        SQLstr = "SELECT DISTINCT province FROM hotspot WHERE province<>'Null' AND province<>'N/A' AND province<>'Not Applicable'"
      
     
     arrprovince = DB_Query(strConnection,SQLstr,dbrt_GetRowsArray)
      
     IF IsArray(arrprovince) THEN
      numprovinceRows = Ubound(arrprovince,gr_rows)
     ELSE
      numprovinceRows = -1 
     END IF
        
      
        
        
        SQLstr = "SELECT DISTINCT city FROM hotspot WHERE city<>'Null' AND city<>'N/A' AND city<>'Not Applicable' AND city<>'?' AND city<>'0'"
      
     arrcity = DB_Query(strConnection,SQLstr,dbrt_GetRowsArray)
      
     IF IsArray(arrcity ) THEN
      numcityRows = Ubound(arrcity,gr_rows)
     ELSE
     numcityRows = -1 
     END IF
        
    
    
    
    %>
    
    
    <!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>
    
        <title>Hotspot Finder</title>
    </head>
    <body style="font-size: 12pt">
    <table>
            <tr>
                
                <td style="width: 265px; height: 1px">
                    <strong><span style="font-size: 14pt">Country</span></strong></td>
                <td style="width: 263px; height: 1px">
                    <span style="font-size: 14pt">&nbsp;<strong>Province</strong></span></td>
                <td style="width: 456px; height: 1px">
                    &nbsp;<span style="font-size: 14pt"><strong>Town</strong></span></td>
            </tr>
            <tr>
                <td style="width: 265px; height: 21px">
                    &nbsp;<select id="Select3" style="width: 158px" onclick="return Select1_onclick()">
                
          
          
         <%FOR i = 0 TO numcountryRows %>
       <option selected="selected">       
                <%=arrcountry(0,i)%>
             
    </option>
        
     <%NEXT%>       
                </td>
                <td style="width: 263px; height: 21px">
                        <select id="Select1" style="width: 158px" onclick="return Select1_onclick()">
                
                
         <%FOR i = 1 TO numprovinceRows %>
       <option selected="selected">       
                <%=arrprovince(0,i)%>
             
       </option>
            
       <%NEXT%>
                           <option></option>
            </select></td>
                <td style="width: 456px; height: 21px">
        
                   <select id="Select2" style="width: 158px" onclick="return Select2_onclick()">
                
                
         <%FOR i = 0 TO numcityRows%>
       <option selected="selected">       
                <%=arrcity(0,i)%>
             
       </option>
            
       <%NEXT%>
                        
                              <option></option>
            </select></td>
            </tr>
            <tr>
                <td style="width: 265px">
                </td>
                <td style="width: 263px">
                    </td>
                <td style="width: 456px">
                </td>
            </tr>
        </table>
           
    </body>
    </html>
    If someone could help me with the code I will need to do this I appresiate it very much.

    Regards

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I don't know ASP, but I can describe the general process, based on my experience with PHP.

    Both of these languages output the html source for a page, including javascript and CSS.

    For example:
    <?php echo 'var n = 3;' ?>

    That would output some Javascript.

    So, in the same sense, you ASP should simply output the text that should be the javascript at the exact place in the source code. It's just like outputting html in how you would do it with ASP.

    I'd suggest, perhaps, a loop, where it would output 'menu[0] = "text";', then for menu[1], etc etc., depending on what you want as the output.

    For the first step, I would write out, by hand, what an example output should be, then you can figure out how to achieve that using ASP, outputting each section.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, dont reallt understand your advice, is there no easier way to do something like this ?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •