By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,012 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

dynamically populate drop down menu option value problem

P: n/a
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>
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Enclose your values in quotes.

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

Ray at home

--
Will trade ASP help for SQL Server help
"julian" <ju***********@talk21.com> wrote in message
news:19**************************@posting.google.c om...
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>

Jul 19 '05 #2

P: n/a
thx ray.
always boils down to punctuation!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3

P: n/a
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)
"julian" <ju***********@talk21.com> wrote in message
news:19**************************@posting.google.c om... 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>

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.