Linked Database Pulldowns

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Linked Database Pulldowns

    Hi Everyone,

    I have a problem, and it's causing me to tear my hair out...

    On allhvacinfo.com, they have pulldowns which are linked together... The
    first pull down has values that come from a database, selecting one of the
    options in that pulldown menu load another pulldown menu and in that menu
    are more options loaded from the database that can be selected.

    How do I do this?

    I need something quick and dirty before the end of the day...

    Thanks,

    Justin
    --
    Mallorie Jones
    [email]MallorieJones@sympatico.ca[/email]
    (416)444-5999


    Mallorie Jones Guest

  2. Similar Questions and Discussions

    1. Object Color linked to database
      This is what I want to do.... I want to set up a FLASH page which consist of objects say a square grid (each square is 1 object). The indidvidual...
    2. CF pulldowns
      When I display a field from a database query in a form using CFForm and include a pulldown list on that field the pulldown options overwrite the...
    3. Copying the linked info into current database
      I have 2 databases, a Customer Database and a Sales Database. The Customer Database has Name, bill to address, Phone, Fax, etc. Sales Database has...
    4. Flash file linked to database???
      Hi, I'm developing an e-Learning application using Flash MX. Instead of adding text directly to the flash file, I'd prefer to link the flash...
    5. Problem with Access Database With Linked Text File
      Hi, I'm using an Access 2000 database with my ASP application, and the db has a link to a text file. Previously, the text file and the db were...
  3. #2

    Default Re: Linked Database Pulldowns

    look here:

    Multiple dependent lists
    [url]http://www.aspkey.net/aspkey/_articles/asp/articles.asp?#100[/url]

    ================================
    [url]http://www.ASPkey.net/[/url]
    A Resource Site for Web Developers
    *Free OnLine web Tools
    *Free development services
    ================================


    "Mallorie Jones" <malloriejones@sympatico.ca> wrote in message
    news:b_vab.2731$Ie5.615748@news20.bellglobal.com.. .
    > Hi Everyone,
    >
    > I have a problem, and it's causing me to tear my hair out...
    >
    > On allhvacinfo.com, they have pulldowns which are linked together... The
    > first pull down has values that come from a database, selecting one of the
    > options in that pulldown menu load another pulldown menu and in that menu
    > are more options loaded from the database that can be selected.
    >
    > How do I do this?
    >
    > I need something quick and dirty before the end of the day...
    >
    > Thanks,
    >
    > Justin
    > --
    > Mallorie Jones
    > [email]MallorieJones@sympatico.ca[/email]
    > (416)444-5999
    >
    >

    TJS Guest

  4. #3

    Default Re: Linked Database Pulldowns

    Dependent Listboxes

    You can use dependent listboxes for example to let a user choose a rep
    in a reps listbox and then have only the customers for that rep be shown
    in the customers listbox.

    You can see an example of this on the ASP Web database demo on my site
    [url]www.bullschmidt.com/login.asp[/url] and then go to the Invoices dialog and
    choose a rep in the listbox and notice that the page is posted to
    itself, the customers listbox then gets the focus, and the customers
    listbox only contains the customers for that rep.

    I'd suggest having the onchange event for the first listbox (called
    RepID) use JavaScript to submit the page (assuming the page is being
    posted back to itself anyway) and then if the page is a post, show the
    extra info in the second listbox.

    Example:
    <select name="RepID" size="1" onchange="RefreshPg('CustID');">

    And the SQL for the second listbox (called CustID) would be something
    like this:
    strSQL = "SELECT CustID "
    strSQL = strSQL & "FROM tblCust "
    strSQL = strSQL & "WHERE (1=1) "
    If Request.Form("RepID") <> "" Then
    strSQL = strSQL & "AND (CustUserID=" & Chr(39) & Request.Form("RepID")
    & Chr(39) & ") "
    End If
    strSQL = strSQL & "ORDER BY CustID"

    And on the form have a hidden field which will contain the name of the
    field to be given the focus when the page is reopened.

    Example:
    <input type="hidden" name="FocusedFldName" value="<%=
    Request.Form("FocusedFldName") %>">

    And somewhere on the page:
    <% ' Set focus.
    If Request.Form("FocusedFldName") <> "" Then
    ' Set focus based on FocusedFldName.
    %>
    <script type="text/javascript">document.frmMain.<%=
    Request.Form("FocusedFldName") %>.focus();</script>
    <% Else
    ' Set focus.
    %>
    <script type="text/javascript">document.frmMain.RepID.focus();</script>
    <% End If %>

    And here's the JavaScript function to submit the page for this purpose:

    function RefreshPg(pstrFldName) {
    // Purpose: Refresh pg. to update other fld(s) based on selection.
    // Remarks: Used by listbox's onchange.
    // Assumes existence of document.frmMain.FocusedFldName hidden fld.

    // Set focused fld for when come back.
    document.frmMain.FocusedFldName.value = pstrFldName;

    // Msg.
    alert("Refreshing page to update other field(s) based on your
    selection.");

    // Submit pg to itself to refresh other combo based on this combo.
    document.frmMain.submit();
    }

    And here are some final notes of clarification.

    FocusedFldName is the name of a hidden field on the form. It is usually
    blank but after the user changes the parent listbox (called RepID)
    JavaScript code puts in the name of the child listbox (called CustID)
    into the hidden field (called FocusedFldName) on the form.

    Then when the page is reopened JavaScript sets the focus on the name of
    the field (i.e. the name of the child listbox) contained in the hidden
    field. Thus the focus is set on the CustID field (instead of the RepID
    field which gets the focus when the form is FIRST opened).

    And if the RepID field in the database is a numeric field then the
    Chr(39) stuff is not needed so this:
    strSQL = strSQL & "AND (CustUserID=" & Chr(39) & Request.Form("RepID")
    & Chr(39) & ") "
    Should be changed to this:
    strSQL = strSQL & "AND (CustUserID=" & Request.Form("RepID") & ") "

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    [url]http://www.Bullschmidt.com[/url]
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt Guest

  5. #4

    Default Re: Linked Database Pulldowns

    you're just like a little puppy dog... follow me everywhere I go.


    TJS Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139