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

  • SEARCH
  • Home
  • 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 8023989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:43:52+00:00 2026-06-04T22:43:52+00:00

I have a simple bit of code that is filling a select object from

  • 0

I have a simple bit of code that is filling a select object from a db table. I want to check a value to set an entry as selected, but when I check a db value, I get an empty select box. This code produces the empty box:

response.write "<td><select name='FromDept'>"
Do While not rs.eof
   If rs("DeptID")  = 61 Then 
      response.write "<option value=" & rs("DeptID") & " selected>" & rs("DeptName")     & "</option>" 
   Else    
      response.write "<option value=" & rs("DeptID") & ">" & rs("DeptName") & "</option>"
   End If 
   rs.MoveNext     
Loop
rs.close
response.write "</select></td>"

However, this code produces a select box with values:

response.write "<td><select name='FromDept'>"
LpCnt = 0 
Do While not rs.eof

    If LpCnt = 9 Then 
       response.write "<option value=" & rs("DeptID") & " selected>" & rs("DeptName") & "</option>" 
    Else    
       response.write "<option value=" & rs("DeptID") & ">" & rs("DeptName") & "</option>"
    End If 
    rs.MoveNext     
    LpCnt = LpCnt + 1 
Loop
rs.close
response.write "</select></td>"  

Thanks for any help!

  • 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-06-04T22:43:53+00:00Added an answer on June 4, 2026 at 10:43 pm

    Assign the value to a temporary variable:

    response.write "<td><select name='FromDept'>"
    Do While not rs.eof
       dept = rs("DeptID")
       If dept  = 61 Then 
          response.write "<option value=" & dept & " selected>" & rs("DeptName")     & "</option>" 
       ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple bit of code that outputs the stream from a google
I have a very simple bit of code that is supposed to capture the
So I have a simple bit of code that re-sizes my profile images as
I have the following simple bit of code that is crashing and it's not
I have a bit of code that concatenates text from some input boxes and
I want to create a simple bit of JS code that creates an image
I have a very simple bit of code that won't work, and have no
I have a pretty simple ASP.NET Web Form that looks a bit like the
I have (well had) a bit of code that would get me my lovely
So I inherited a bit of code that's waiting for communication from a network

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.