dynamically populate drop down menu option value problem

J

julian

hi

I was wondering if anyone can help me out on this....

I have dynamcally populated a drop down menu with data from an access
database using ASP. The values seem fine, however when i pass them to
the next page (using form get method) the whitespaces in the values
are ignored. For example with <option value=jim jones> then only "jim"
gets passed to the next page not "jim jones". I have viewed the source
created on the dynamic page and the values are populated fine, but
passing to the next page seems to be problematic...

My code....

<form name="search2"
<%if registered then%>
action="xresults1.asp"
<%else%>
action="xresults.asp"
<%end if%>
method="get">

<%

if isempty(Application("Recordset2strcacheUsers")) then

Set db = Server.CreateObject("ADODB.Connection")
db.Open MM_database2_STRING

Set Recordset2 = db.Execute("SELECT DISTINCT Field2 FROM IaxData WHERE
Field19 = '1'")

'*******populate drop down list********

Recordset2str = "<SELECT NAME=subject><OPTION
value=choose>Subject</OPTION>"
while not Recordset2.eof
Recordset2str = Recordset2str & "<OPTION VALUE=" &
Recordset2.fields("Field2") & ">" & Recordset2.fields("Field2") &
"</OPTION>"
Recordset2.moveNext
wend

Recordset2str = Recordset2str & "</SELECT>"
Response.write("<br>from database<br>" & Recordset2str)

'********write to cache***********
Application.lock()
Application("Recordset2strcacheUsers") = Recordset2str
Application.unlock()

db.Close
Set db = Nothing

else
' Write from cache
Response.write("<BR>from cache<BR>" & Application
("Recordset2strcacheUsers"))

end if
%>

</form>
 
R

Ray at

Enclose your values in quotes.

Recordset2str = Recordset2str & "<OPTION VALUE=""" &
Recordset2.fields("Field2") & """>" & Recordset2.fields("Field2") &
"</OPTION>"

Ray at home
 
L

Lord Unspecified

you need to enclose the value with ""... i.e.
Recordset2str = "<SELECT NAME=subject><OPTION
value=choose>Subject</OPTION>"
while not Recordset2.eof
Recordset2str = Recordset2str & "<OPTION VALUE=""" &
Recordset2.fields("Field2") & """>" & Recordset2.fields("Field2") &
"</OPTION>"
Recordset2.moveNext
wend

Recordset2str = Recordset2str & "</SELECT>"
Response.write("<br>from database<br>" & Recordset2str)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top