DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Passing a Select box variable to a sql statement

Hybrid View

  1. #1
    Ed Guest

    Passing a Select box variable to a sql statement


    I have have a select box with 8 option items, named venues. The select box
    is surrounded by form tags. Once the selection is made I want to pass that
    value to a sql statment to retreive records based on it. How do I do it?

  2. #2
    Russell Jones Guest

    Re: Passing a Select box variable to a sql statement

    When the user submits the form, you can retreive the selected item from the
    Request object, using the name of the select control, e.g.

    dim selectedItem
    selectedItem = Request.Form("selectControlName")

    ' always check to ensure something was selected
    if selectedItem = "" then
    ' take appropriate action
    Response.write "You must select an item."
    else
    ' construct your SQL statement here
    ' by concatenating the selectedItem value into the statement, or
    ' (preferable) pass the selectedItem value as a parameter to a stored
    procedure.
    end if

    Russell Jones
    Sr. Web Development Editor
    DevX.com

    "Ed" <thesixofthem@aol.com> wrote in message news:3a81a1b4@news.devx.com...
    >
    > I have have a select box with 8 option items, named venues. The select

    box
    > is surrounded by form tags. Once the selection is made I want to pass that
    > value to a sql statment to retreive records based on it. How do I do it?




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center