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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Positioning to an option in a dropdown

Status
Not open for further replies.

paulcarey

Programmer
Joined
Jun 15, 2001
Messages
45
Location
GB
How do I position a dropdown to a defined option.

I have a dropdown that is populated from a table.

I can get the id or text variable for the dropdown items from a querystring.

Sections of my code looks like this so far

Any ideas?

Paul

<%
dim ID
dim iSystem
dim sSystem

ID = request.querystring(&quot;KBID&quot;)

set OrigRs = Server.CreateObject(&quot;ADODB.recordset&quot;)
sqlOrig=&quot;Select * FROM tblKnowledgeBase WHERE KBID =&quot; & ID
OrigRs.Open sqlOrig, conn

iSystem = OrigRs.fields(&quot;KBSystemId&quot;)
sSystem = OrigRs.fields(&quot;KBSystem&quot;)

OrigRs.close
%>

<form method=&quot;POST&quot; action=&quot;KBUpdate.asp&quot;>
<table width=&quot;612&quot;>

<td width=&quot;217&quot;>
<font size=&quot;2&quot;>
<%
'SYSTEM DROPDOWN
set rs = Server.CreateObject(&quot;ADODB.recordset&quot;)
sqlSystem=&quot;Select KBSystemID, KBSystem from tblKnowledgeBaseSystem ORDER BY KBSystem&quot;
rs.Open sqlSystem, conn
%>
System</font>
</td>
<td width=&quot;470&quot;>

<Select Name = &quot;KBSystemID&quot; size=&quot;1&quot;>
<%
If not(rs.EOF AND rs.BOF) Then
rs.MoveFirst
Do until rs.EOF
Response.Write &quot;<option value=&quot; & rs(&quot;KBSystemID&quot;) & &quot;>&quot; & rs(&quot;KBSystem&quot;) & &quot;</option>&quot;
rs.MoveNext
Loop
End If
rs.close
%>
</select>
</td>
 
If not(rs.EOF AND rs.BOF) Then
rs.MoveFirst
Do until rs.EOF
sel=&quot;&quot;
if ID=cstr(rs(&quot;KBSystemID&quot;)) then
sel=&quot;selected&quot;
end if
Response.Write &quot;<option value=&quot; & rs(&quot;KBSystemID&quot;) & &quot; &quot;&sel&&quot;>&quot; & rs(&quot;KBSystem&quot;) & &quot;</option>&quot;
rs.MoveNext
Loop
End If


Known is handfull, Unknown is worldfull
 
Thanks for that but no joy though
 
meaning????

Known is handfull, Unknown is worldfull
 
meaning????

No errors, no result
 
try converting both to Int instead before comparing...
Code:
If CInt(ID) = CInt(rs(&quot;KBSystemID&quot;)) Then
  sel = &quot;SELECTED&quot;
End If

Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
er what do u mane by no joy? what was the error?

Known is handfull, Unknown is worldfull
 
Thank you FesterSXS that seemed to do it!

vbKris,
I meant didnt work but didnt throw an error
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top