ASP: Retrieving database data using drop-down menu

Posted on 2004-10-26
Last Modified: 2010-04-06
I am trying to retrieve data from an ACCESS database in ASP code such as

 sql="SELECT * FROM tablewithdata WHERE mydata =' & request("myformdata") & ' "

This is working if MYFORMDATA is the name element of a INPUT textbox-stand alone- on my form but it is not working if this is the name of the SELECT element of a drop-down menu with a number of options.

What am I missing??
Its a simple question but I will not be mean with the points!

Question by:billysaw
    LVL 13

    Expert Comment

    check the drop down menu name

    it may conflict with another form element

    try to check the value  
    response.write (Request("dropdown_name"))


    Author Comment


    Is the "dropdown_name" the name of the FORM or the name of the SELECT?
    LVL 13

    Expert Comment

    name of the SELECT box
    LVL 3

    Accepted Solution

    A select list contains options which each have their own value... make sure that the option you select has a value or Request("dropdown_name") will have a null value (or maybe an empty string?)... like this:

    <select name="dropdown_name">
      <option>Select Color</option>             <-- returns ""
      <option value="FF0000">Red</option> <-- returns "FF0000"
      <option value="00FF00">Green</option> <-- returns "00FF00"
      <option value="0000FF">Blue</option>  <-- returns "0000FF"

    so, if the option you selected has no value the sql statement looks like this:
    SELECT * FROM tablewithdata WHERE mydata = ''
    which is probably not what you want...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Suggested Solutions

    Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
    There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now