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

Drop Down Menus 1

Status
Not open for further replies.

spiff1971

Programmer
Jan 5, 2004
4
CA
Hello,

I am experiencing some problems creating a drop down menu that is populated from a database. The problem is when the page is submitted, it doesnt populate the drop down menu with the selection.

The info from the database is populated into an array and fed into the form....

The database is basically like this:
PlanID (autonum) PlanName (text)
1 First Plan Name
2 Second Plan Name

I have noticed that when I compare Plan Name to Plan Name, it populates the correct answer. However, when I compare PlanID with the answer in request.form, it doesnt work.

Does the fact I am comparing a number have anything to do with it?

Appreciate your help!

spiff

'populating drop down menus
set rsold = connection.execute("Select * from oldplan order by Plan asc")
oldlist = rsold.getrows()
const oldid = 0
const old_plan = 1

if request.form.count > 1 then
theoldplan = request.form("oldplan")
end if

Old Plan:
<select size=&quot;1&quot; name=&quot;oldplan&quot;>
<option value=&quot;0&quot;>Select the old plan</option>
<% for i = 0 to ubound(oldlist, 2) %>
<option value=&quot;<%= oldlist(oldid, i) %>&quot;
<% if theoldplan = oldlist(oldid, i) then response.write &quot;selected&quot; %>><%= oldlist(old_plan, i) %> - <%= oldlist(oldid, i) %></option>
<% next %>
</select>

This is the gist of it. If I change everything to oldlist(old_plan, i), then it works perfectly.

Thanks

 
You got it in one. The value coming from Request.Form is in string format, while your autonumber is in numeric. Considering the way VB handles variables this shouldn't make a difference, but I have run intoi the same exact issue in the sam,e exact circumstances before. try either using cStr on the value from the db or cLng/cDbl/cInt on the one from Request.Form. Should straighten it right out.

-T

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