Previous Next

Thread: classic asp, when combobox option selected make db call

Last post 05-12-2008 9:13 AM by tomkmvp. 15 replies.

Average Rating Rate It (5)

RSS

Page 1 of 2 (16 items) 1 2 Next >

Sort Posts:

  • 05-04-2008, 11:39 PM

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    classic asp, when combobox option selected make db call

    I have a classic asp combobox and when an option is selected on it i need to fire javascript that will then call a vb script function that will query a database to return values to fill combobox number 2.

    The vbscript will create the sql query and query the db, return the recordset and then bind to the second combo box.  the thing that is tricky is getting the vbscript to be called from the combobox selection, not sure how to do this.

    EX:  make a selection on Combo1 and then query database based on the value selected and use the records returned from the database to populate Combo2.

    Does anyone have any code samples of this?  Can this be done or do I have to use some other scripting language?

    thanks

  • 05-05-2008, 8:37 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,538
    • IIS MVPs
    • tomkmvp

    Re: classic asp, when combobox option selected make db call

    You need to create a client-side script to handle the select control onchange event, which will then submit the form.
    http://msdn.microsoft.com/en-us/library/ms536912(VS.85).aspx

  • 05-05-2008, 9:41 AM In reply to

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    Re: classic asp, when combobox option selected make db call

    thanks again Tom, appreciate the help:

    so you are saying that I will need to submit the form, load the page again.

  • 05-05-2008, 10:17 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,538
    • IIS MVPs
    • tomkmvp

    Re: classic asp, when combobox option selected make db call

  • 05-05-2008, 10:42 AM In reply to

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    Re: classic asp, when combobox option selected make db call

    thanks,

    is there anyway to fire javascript when user selects an option from the combobox and then have that javascript function call a vbscript function which will query the database based on the combobox selection?

  • 05-05-2008, 11:05 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,538
    • IIS MVPs
    • tomkmvp

    Re: classic asp, when combobox option selected make db call

    Is the vbscript client-side or server-side?

  • 05-05-2008, 11:08 AM In reply to

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    Re: classic asp, when combobox option selected make db call

    the vbscript is in the asp page, so i guess that would client-side.

  • 05-05-2008, 12:16 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,538
    • IIS MVPs
    • tomkmvp

    Re: classic asp, when combobox option selected make db call

    There is some old remote data technology but I think your best bet is to submit the form which will then reload the ASP and run the server-side code.

  • 05-05-2008, 4:06 PM In reply to

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    Re: classic asp, when combobox option selected make db call

    thanks again,

    would it be possible to use AJAX with Classic ASP to hit the db?

  • 05-05-2008, 4:17 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,538
    • IIS MVPs
    • tomkmvp

    Re: classic asp, when combobox option selected make db call

    Maybe - I only have AJAX experience with ASP.NET though.  You would have to research that.

  • 05-05-2008, 8:35 PM In reply to

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    Re: classic asp, when combobox option selected make db call

    what if I create a second recordset on initial pageload and then when you select the first combobox then bind the filterered second recordset to the second combobox.

    Can you bind a recordset to a combobox on a javascript call?

  • 05-06-2008, 8:38 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,538
    • IIS MVPs
    • tomkmvp

    Re: classic asp, when combobox option selected make db call

    Where would the recordset reside?

  • 05-06-2008, 12:41 PM In reply to

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    Re: classic asp, when combobox option selected make db call

    The recordset is on the same asp page as the comboboxes.

     

    Also another thing:

    My combobox is like this:

     

    <select onchange="BLOCKED SCRIPT__StyleChanged()" name="PopulateStyle" size="1" style="width:400px">

    <option value="0~">No Style Selected</option>

    <%

    While not rsStyle.EOF

    %>

    <option value="<%=rsStyle("Style_Name")%>">

    <%=rsStyle("Style_Name")%>

    </option>

    <%

    rsStyle.MoveNext

    Wend

    If rsStyle.State = adStateOpen Then rsStyle.Close

    Set rsStyle= nothing

    %>

    You see that I display the Style_name and the value is the style_name.

    I want to change this so the value will be a StyleID from the recordset and I still want to display the Style_Name to the user, but after this I need to know how to get both the Style_Name and the Style_Id.

    I will use the selected STyle_Id to filter the second recordset and then I want to bind this recordset to the second combobox.

    I have a Javascript function now that gets the .value which is now the Style_Name so I know if I change the value to be StyleID then it will get that, so I know how to change that.

    But I also need to know the javascript syntax to get the style_name or selected value, what is the syntax for that?  Is it something like option[s].selected?

    What I have now is this, this gets the value.  How do you get the selected text? (it must be something similar to this):

                var vl;

                vl = document.frmSend.PopulateStyle.options[s].value;

  • 05-06-2008, 2:37 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,538
    • IIS MVPs
    • tomkmvp

    Re: classic asp, when combobox option selected make db call

    MyronCope:
    The recordset is on the same asp page as the comboboxes.
    I think you're getting client-side and server-side concepts all mixed up.

    MyronCope:
    But I also need to know the javascript syntax to get the style_name or selected value, what is the syntax for that?  Is it something like option[s].selected?
    http://www.w3schools.com/js/tryit.asp?filename=try_dom_option_settext

  • 05-10-2008, 8:18 PM In reply to

    • MyronCope
    • Top 150 Contributor
    • Joined on 02-07-2005, 9:30 AM
    • Posts 21
    • MyronCope

    Re: classic asp, when combobox option selected make db call

    my last post was a side question, but I still want to find out how to query the database on selection of a combobox without refreshing the page, i know this is essentially some form of Ajax.

    I know how to make the javscript fire when you change a combobox.

    I know how to query a database from an asp page.

    I just need to know the missing link in the middle, making the connection between the javascript and the server.

Page 1 of 2 (16 items) 1 2 Next >
Page view counter