How to get selected value of select tag in ASP?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: How to get selected value of select tag in ASP?

  1. #1
    Join Date
    Jul 2007
    Posts
    17

    Question How to get selected value of select tag in ASP?

    Hi friends,
    Now i m working in a sample ASP program. In that i want to get the Customer name from the database according to the selected Customer No given in the <select> tag.
    For that i want to get the selected value of the <select> tag. I want the coding in VB.script. Can anyone help me?


  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Your select should be something like this, right?
    Code:
    <select size="1" name="sel1">
    <option value="c1">Choice 1</option>
    <option value="c2">Choice 2</option>
    <option value="c3">Choice 3</option>
    <option value="c4">Choice 4</option>
    </select>
    Notice the word value="c1" in the option tag. This is responsible for sending the "c1" to the browser using the submit button. To get it back in another page, try something like this
    Code:
    <&#37;response.write request.querystring("sel1")%>
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Jan 2010
    Posts
    1

    Thumbs up

    Quote Originally Posted by sundar.doubts View Post
    Hi friends,
    Now i m working in a sample ASP program. In that i want to get the Customer name from the database according to the selected Customer No given in the <select> tag.
    For that i want to get the selected value of the <select> tag. I want the coding in VB.script. Can anyone help me?

    heya....u r workin wid database in asp..so ol pages wud b in asp....but il try 2 make it simple 4 u..
    1st u make a form in wich write d followin code

    <form method="get" action="cust_name.asp">
    <select name="sel1">
    <option value="o1">cust1</option>
    <option value="o2">cust2</option>
    .
    .
    .
    .
    n so on...okk
    </select>
    nw make d asp page cust_name.asp write d followin
    cust_no=request.querystring("sel1")
    open d database...den use dis cust_no to extract d value of cust name...ok
    still if u wanna knw hw 2 use select value in vb...heres d code


    if f1.sel.selectedindex=0 then
    customername="anjali"
    elseif f1.sel1.selectedindex=1 then
    customername="sid"
    end if

    in dis f1 is d name of d form....bt u wont b able 2 use a database in dis..
    i hope u understud....i wud really lyk 2 knw if im a help 2 u..
    mail me at Email address removed....
    Last edited by Hack; 01-22-2010 at 07:15 AM. Reason: Removed EMail Address

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    I have edited your post and removed your email address.

    You should never post your email address in an open post on an open forum. Mail spam bots can pick that up and before you know it, your mailbox is full of junk mail. If you wish to share your email address with other forum members, please do so via our PM system.

    But even more importantly than that, we prefer all answers to questions be publically posted rather than sent via EMail or PM. That way, everyone with a similar problem can benefit.

    Thanks.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. SQL Select into ASP Array
    By drew in forum ASP.NET
    Replies: 1
    Last Post: 02-27-2003, 04:51 AM
  2. Replies: 1
    Last Post: 04-24-2002, 08:08 PM
  3. Replies: 0
    Last Post: 11-02-2001, 03:42 PM
  4. Select statement in ASP
    By Victor Tai in forum Web
    Replies: 1
    Last Post: 07-24-2000, 11:43 AM
  5. Using the HTML SELECT TAG in an XSL document
    By Henry White in forum XML
    Replies: 0
    Last Post: 04-22-2000, 04:08 AM

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