Results 1 to 12 of 12

Thread: List Boxes and Array

  1. #1

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303

    Question

    I'm quite new to ASP, so please bear with me.

    I've got a simple list that displays informations from a database. What I want to be able to do is select an item from the list and for it to fill in the rest of the details on the screen?

    Hows it done?
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  2. #2
    bubba
    Guest
    Place the drop down list on a form, set the forms action to reload the current page. Pass the value from the dropdown list to an SQL query:


    Code:
    <form METHOD="POST" ACTION="parkes.asp" >
        <SELECT NAME="Users" SIZE="1">
            <OPTION VALUE="Bubba">Bubba
            <OPTION VALUE="Parkes">Parkes	
        </SELECT>
    
    <INPUT TYPE="SUBMIT" NAME="ACTION" VALUE="Select User">"
    </form>
    
    Elsewhere in your asp........
    
    If Request("Action") = "Select User" Then
        'run your sql query like
        "Select * from tblUsers where username = '" & request("users") & "'"
    End if

  3. #3

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    I'd like to be able to do this without reloading the page. I've seen it done, just cannot get to the code?
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  4. #4
    bubba
    Guest
    You can't post new data too a page without reloading/refreshing it.

  5. #5
    Junior Member
    Join Date
    May 2001
    Location
    Georgia
    Posts
    20
    Parkes,

    I think Bubba is right. You'd have to reload the page. Except for one thing: if you're right about seeing it before, then it was probably XML and XSL. That's the beauty of XML - you pull all the data in at once (instead of multiple trips to the database every time a new selection is made), then you can sort the data right there on the screen. XML is actually not that hard. Check it out. It is probably what you need.

  6. #6
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    If you had the stuff stored in say a client side array, then you could update it dynamically. But it is not possible to get info from the DB on the fly like that.

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  7. #7
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    It would have to be a small set of data too. Otherwise your page will be huge when it is downloaded. I have used the arrays technique to have cascading dropdowns.. one selection filters the next etc..

    But if you have more than say 20 possibilities in the first dropdown, I wouldn't use this method.. An XML doc would be another answer..
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  8. #8
    Lively Member
    Join Date
    Nov 2000
    Location
    Pakistan
    Posts
    80
    conn.open
    set rsup=server.CreateObject ("adodb.recordset")

    sSQL="select * from prodcat "
    rsup.Open sSQL,conn,adOpenStatic,adLockPessimistic ,adcmdtext

    session("prodid")=Request.QueryString("id")
    prodid=session("prodid")
    if prodid="" then
    prodid="select"
    end if


    <% Response.Write "<select name='menu1' onChange =MM_jumpMenu('self',this,0)>"

    Response.Write "<option selected>" & prodid & "</option>"
    while not rsup.EOF
    Response.Write "<option value='receivingchallan.asp?id="& rsup("styleno")& "' >" & rsup("styleno") & "</option>"
    rsup.MoveNext
    wend
    Response.Write "</select>"
    rsup.Close
    set rsup=nothing

    %>
    Elsewhere in your asp........

    If Request.querysting("id")<>"select" then
    'run your sql query like
    "Select * from products where prodid = '" prodid & "'"
    End if


    <head>
    <script language="JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    </script>
    </head>



    Adeel Ahmed

  9. #9
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    I don't really see how that will work...

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  10. #10
    Lively Member
    Join Date
    Nov 2000
    Location
    Pakistan
    Posts
    80

    Talking

    Its not the game of KIDS



    Adeel Ahmed

  11. #11
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    What the hell is that supposed to mean?

    adeelahmed: Your code does nothing to address his problem

    parkes: If you have a large number of options in the first select that would effect the other controls, use an XML file and load it into the document on the client side. If not, then build client side arrays to hold all of your data and just switch between the values in the onchange event of the select tag.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  12. #12
    Lively Member
    Join Date
    Nov 2000
    Location
    Pakistan
    Posts
    80
    Apologize!



    Adeel Ahmed

Posting Permissions

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



Click Here to Expand Forum to Full Width