Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDown menu - display 1st item

Status
Not open for further replies.

LebronJames

Programmer
Apr 5, 2003
93
I have a drop-down list that is displaying the values taken from a Access 2000 database. How can I get the first item in the list to be the value contained within a variable..


Variable = Mike


List: (when loaded up)

Allan
Bruce
Sean
Mike
David

I want the firs item to be the item in my variable... I have over 300 names please take that into consideration.

When I submit my page the item selected is no longer the first item in the drop-down menu. Is there a work aroud for this?
 
so you have one page that they some how select a name and then submit to the next page that loads a select with a list 300+ some other names.

if that is correct then you just need to add some conditioning to the loop on the recordset to cehck and see if the value passed (being the name to select) is equal to the name that is currently cursored on.

something to the effect of
Code:
Do While NOT RS.EOF
 If Trim(UCase(Request.Form("myName"))) = Trim(UCase(RS("names"))) Then
   Response.Write "<option selected>" & RS("names")
 Else
   Response.Write "<option>" & RS("names")
 End If
RS.MoveNext
Loop

___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page faq333-3811
 
Or if, instad of being selected, you wantit to literally be the first item in the list:
Code:
Response.Write "<option selected>" & Request.Form("myName") & "</option>"
Do Until RS.EOF
   If Trim(UCase(Request.Form("myName"))) <> Trim(UCase(RS("names"))) Then
      Response.Write "<option>" & RS("names") & "</option>"
   End If
   RS.MoveNext
Loop

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
maybe we need a benchmark on those two methods. lol

___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page faq333-3811
 
Heh, I wonder...you think InStr would be a faster comparison than multiple trim(ucase()) calls? or maybe a regex object with ignore case?

Hmm...to much to do to test that right now...

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top