Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6840073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:47:47+00:00 2026-05-26T23:47:47+00:00

below is my ASP classic code.i having a problem when put if else statement

  • 0

below is my ASP classic code.i having a problem when put if else statement like that..actually it’s not working..what i want to do is when i select USA then submit it will show selected USA..default is ALL.sorry for my bad English.

<% Response.write"<form action=""untitled.asp"" method=""post"">"
   Response.write"<select name=""country"">"
   Response.write"<option selected>ALL</option>"
   Response.write" <option value=""1"" if request(""country"")=""1"" then 
   Response.Write""selected"">USA</option>"
   Response.write" <option value=""2"" if request(""country"")=""2"" then 
   Response.Write""selected"">BRAZIL</option>"
   Response.write"<label>"
   Response.write" <input type=submit name=button id=button value=Submit />"
   Response.write"</label>"
   Response.write"</form>"
%>

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:47:47+00:00Added an answer on May 26, 2026 at 11:47 pm

    Your basic syntax is wrong. This is how it should be done:

    Response.write " <option value=""1"""
    If request("country")="1" then 
        Response.Write " selected=""selected"""
    End If
    Response.Write ">USA</option>"
    

    And same for the second option. To make it more flexible and readable, use a function:

    Function BuildOption(sValue, sRequestKey, sText)
        Dim sHTML
        sHTML = "<option value=""" & sValue & """"
        If Request(sRequestKey)=sValue Then 
            sHTML = sHTML & " selected=""selected"""
        End If
        sHTML = sHTML & ">" & sText & "</option>"
        BuildOption = sHTML
    End Function
    

    Then use it like this:

    Response.write BuildOption("1", "country", "USA")
    Response.write BuildOption("2", "country", "BRAZIL")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert below SQL Server code to VBScript in classic ASP... DECLARE
I have the same problem as below: ASP.NET MVC 3 ValidateRequest(false) not working with
Technology Used:- Asp.Net 2.0 Code:- See Below Description:- hello code given below is working
If I had an ASP.NET 4.0 DataView control that looked like below, how can
I am working on a classic asp form that has a number of dropdowns.
I want to create an ASP.NET virtual dir below a classic ASP WebSite. The
I have the below code to display a simple table in a classic asp
How would I handle something like the below uri using ASP.NET MVC's routing capability:
I created a DatePicker user control (ASP code below, no code behind) which is
I was given the code below to disable a button on an ASP.Net page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.