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

Request.Form Problem/Question

Status
Not open for further replies.

cRODEEkrank

Technical User
Dec 5, 2001
41
0
0
US
Hi,

I have a form which contains a select box containing publication titles. The user will select a title and click a submit button. On the next form, I have the following code:
<%
title = request.form(&quot;titlename&quot;)
response.write title
%>

The problem is, only the first word of the value in the &quot;titlename&quot; select box is displaying. For example, if a title named &quot;The Law of Businesses&quot; is selected, only &quot;The&quot; is showing up on the next screen.

Help!!!
J

 
That means that you are missing quote characters around the values of your select box. You can't use
Code:
    value=Alice in Wonderland
The browser might be kind enough to display &quot;Alice in Wonderland&quot; in the list (maybe), but it's still just going to send you &quot;Alice&quot; and will assume that &quot;in&quot; and &quot;Wonderland&quot; are just bad HTML. You need to use:
Code:
    value=&quot;Alice in Wonderland&quot;
or at least
Code:
    value='Alice in Wonderland'
though the latter can getyou into trouble if you have any single-quotes (like an apostrophe) in your string. Safest is:
Code:
    value=&quot;<%=Server.HTMLEncode(&quot;Alice in Wonderland&quot;)%>&quot;
 
Thanks for the suggestion, but I'm still getting the problem. Actually, I'm not using the value directly but am first saving it to a variable:

titlename = request.form(&quot;fulltitle&quot;)

...where &quot;fulltitle&quot; is the name of the <select> control on the previous screen. It's still giving me only the 1st word of the value.
 
Genimuse's solution is correct in this case. And technically you are using the value. When a select box passes a value to the next page it passes whatever happens to be assigned to the value attribute (if nothing then it goes with the text of the option).
Like all things HTML, when you have an attribute with spaces in it's value, the browser thinks the value is finished at the first space. This is to cut down on confusion, such as:
Code:
<option value=i am selected>Selected</option>

Place quotes around any HTML attribute and the browser will read exactly what you want it to as the value for the attribute:
Code:
<option value=&quot;i am selected&quot;>Selected</option>

In the first case the value passed when the form is submitted would be &quot;i&quot;. In the second case it would be &quot;i am selected&quot;.

-Tarwn


[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
minilogo.gif alt=tiernok.com
The never-completed website
 
In my case then, how would I go about this? I don't have a 'value' attirubte for my select:
<select name=&quot;fulltitle&quot;>
...
</select>

Then I am trying to obtain the value on the next page:
titlename = request.form(&quot;fulltitle&quot;)

I've tried the suggestion, maybe not correctly?

titlename = server.HTMLEncode(request.form(&quot;fulltitle&quot;))

However I'm still getting only the first word.
 
The values go in the individual option tags:
Code:
<select name=&quot;selColor&quot;>
<option value=&quot;red minivan&quot;>The Red Minivan!</option>
<option value=&quot;blue landrover&quot;>The Blue Landrover!</option>
<option value=&quot;puke green nova&quot;>The Green Nova!</option>
</select>

-Tarwn

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
minilogo.gif alt=tiernok.com
The never-completed website
 
Thanks so much! It's working for me now. I looked at the HTML source and noticed the value attributes didn't have quotes in them - I made a false assumption they were there. A good lesson for me, that's for sure! :)
 
Those are indeed the values I was referring to.

&quot;Genimuse's solution is correct in this case&quot;? Hey, what are the cases where my solutions aren't correct?!? :)
 
Actually I was just emphasizing that you were correct as it pertains to this specific instance, not that you are usually wrong and happened to luck out this time ;)
Ie, no need to look any further for an answer, we just need to delve deeper into the solution at hand.

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
minilogo.gif alt=tiernok.com
The never-completed website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top