How to select from drop-down box and pass to query

Results 1 to 2 of 2

Thread: How to select from drop-down box and pass to query

  1. #1
    Join Date
    Dec 1969
    Posts
    569

    Default How to select from drop-down box and pass to query

    I have a dropdown box containg part number that is populated from a query. I would like to have the user select a part number and then a query would run to place the corresponding price in a text box.<BR><BR>any suggestions

  2. #2
    Chris Willey Guest

    Default RE: How to select from drop-down box and pass to query

    2 ways to do this:<BR><BR>1) Do it all client-side and have all the prices corresponding to the items on the drop down in an array (also built with ASP), and do the text box bit using Javascript. That might look like this:<BR><BR>&#060;script language="Javascript"><BR>&#060;!--<BR>&#060;%<BR>&#039assume you have created a recordset and have all the records you want<BR>x = 0<BR>Do Until rs.EOF<BR>&#037;&#062;<BR>priceArray[&#060;%=x&#037;&#062;] = &#060;%=rs("price")&#037;&#062;;<BR>&#037;&#062;<B R>x = x + 1<BR>Loop<BR>&#037;&#062;<BR>//--><BR>&#060;/script><BR><BR>Then, use an onchange event handler for the select box:<BR><BR>&#060;select name="select1" onchange="i = document.FORMNAME.select1.selectedIndex; document.FORMNAME.TEXTBOX.value = priceArray[i]"><BR><BR>2) Do it server-side and have the page refresh when they change the select box (also Javascript), and use a session variable or (more likely) a querystring parameter to perform a search and pop the result into the text box.

Posting Permissions

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