Values from a form with spaces ??

D

Davey

I am using ASP to generate some forms based on DB queries from Access.
However, when I encounter a value that contains a space as when this value
is posted to a second form it only contains the text string up to the first
space.....

Code is as below:

Initial form: This generates a list of items returned from the access query
and assigns a radio button to each with a value equal to its name
(objRS("Main_Product")
<%
Response.Write "<INPUT TYPE=RADIO VALUE=" & vbquote & objRS("Main_Product")
& vbquote & " NAME=" & vbquote & "PRODUCT_TYPE" & vbquote & ">" &
"&nbsp;&nbsp;" & objRS("Main_Product") & "<BR>"
%>

After submitting the form the next page's code looks like this:
<%
dim strValue
set strValue = Request.Form("PRODUCT_TYPE")
Response.Write strValue
%>

This seems to work fine except when a value like "Fish Fingers" is selected.
This only returns "Fish" ?????

Can anyone offer some advice ?
Cheers
Davey
 
D

Davey

Thats not an option I am affraid !
The value is also used as display text...

If generating a form with radio buttons in FP, the vaules can contain
spaces, and these spaces are posted across in to the next form ok. Why am I
having this problem with button values that are generated from a Access
query in ASP ????
 
D

Davey

Still not sure why I am having this problem but I have worked round it by
changing my Access query and doing the record lookup again in the second
form and use the Autonumber id as the Radio button value...

Thanks
Davey
 
K

Kevin Spencer

Check the actual HTML generated by the ASP when you get it back. You should
find the answer there. For example, when querying a database to get form
field values, the safest thing to do is to use Server.HtmlEncode(value) in
order to prevent certain characters from being interpreted incorrectly by
the browser.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.
 
M

MikeR

Davy -

server.urlencode(objRS("Main_Product"")) before submitting it to the receiving form.
This should replace the space with a plus sign.

In the receiving page

strValue = Replace(Request.Form("PRODUCT_TYPE"), "+", " "))
This replaces the plus sign with a space.
MikeR
 

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

Top