Select option pulldown menu and request.form problem

N

.Net Sports

I have a select pulldown html menu that takes values from a database,
and then send it to the next page via form action = post for
processing. I have assigned the select box name Category, and when it
goes to the next page, if a category name has a space in it, it will
truncate the category name after the first space. I'm using
Server.URLencode to try and keep the string intact, but the category
name still gets truncated:

'''how i am labeling my select pulldown, with the data for the option
value:
<select name=Category>
response.write "<option value=" & RSCATEGORY("catname") & ">" &
RSCATEGORY("catname") & "</option>"

'''how I am calling the category name on the next page
RSEVENTS("category") = Server.URLencode(request.form("Category"))

TIA for help
NS
 
D

Dan

.Net Sports said:
I have a select pulldown html menu that takes values from a database,
and then send it to the next page via form action = post for
processing. I have assigned the select box name Category, and when it
goes to the next page, if a category name has a space in it, it will
truncate the category name after the first space. I'm using
Server.URLencode to try and keep the string intact, but the category
name still gets truncated:

'''how i am labeling my select pulldown, with the data for the option
value:
<select name=Category>
response.write "<option value=" & RSCATEGORY("catname") & ">" &
RSCATEGORY("catname") & "</option>"

'''how I am calling the category name on the next page
RSEVENTS("category") = Server.URLencode(request.form("Category"))

TIA for help
NS


You need to put the category name inside quotes, either single or double, as
it's the browser that is truncating the category name if there is a space
inside it as without quoting it has to assume that anything after the space
is starting a new attribute.

<select name=Category>
<%
response.write "<option value=""" & RSCATEGORY("catname") & """>" &
RSCATEGORY("catname") & "</option>"
%>

Note that I've added "" before the closing " in the first string part, and
after the opening " for the second string part. Doubling up double quotes
inside a string represents a single literal double quote within the string.
 
E

Evertjan.

Dan wrote on 27 okt 2009 in microsoft.public.inetserver.asp.general:
<select name=Category>
<%
response.write "<option value=""" & RSCATEGORY("catname") & """>" &
RSCATEGORY("catname") & "</option>"
%>

<%
response.write "<option value='" & RSCATEGORY("catname") & "'>" &_
RSCATEGORY("catname") & "</option>"
%>


Note that I've added "" before the closing " in the first string part,
and after the opening " for the second string part. Doubling up double
quotes inside a string represents a single literal double quote within
the string.

Much easier way to visualize mistakes:

<select name='Category'>

<option value = '<% = RSCATEGORY("catname") %>' >
<% = RSCATEGORY("catname") %></option>

</select>
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top