We help IT Professionals succeed at work.

Why INPUT="TEXT" and TEXTAREA problem

cwh asked
Medium Priority
Last Modified: 2010-04-09
Hi all,


Whenever I enter data to the text box (INPUT="text"), I can enter all the data including spaces. And when I grab text from the text box, it gives me the whole string. However, if my string contain space (" "), I can't put the whole string to the box.

For example, if I have a textbox name="Address", and I got it from

strAddr=Request.Form("Address") '(in ASP)

I tried to do

<INPUT TYPE="text" Name="Addresss" Value=<%= strAddr%>>
It fails! It give me only the first WORD, and whatever after a space is not shown here. But if I prompt the strAddr with

Response.Write strAddr

I got the whole string. Why is this happen? I have to use <TEXTAREA> instead for all the string that I think user might input space?

Please advise.

Thank you

Watch Question



By the way, I am using PWS in Windows98 as my web server.


when u submit a page for asp processing the asp delimits the string by space. i.e if u have a variable var1 and u send a,b,c,d then it is send to the processing page as a b c d and when u read from the collection u r provided only the first item. to read all the items check the count of the request variable and if the count is > 1 then read all the variables.

instead  u want to collect it as a single variable u can encode the value by using replace thru which u can replace the space in variable to (+). hence u can get a single collection and can read the whole variable with single request.form statement.. but u need to replace + to " " in the processing page..

all the best

Hi cwh,
 I think no need of using Textarea.

You are using the Code :  

  strAddr=Request.Form("Address") '(in ASP)

  I tried to do

  <INPUT TYPE="text" Name="Addresss" Value=<%= strAddr%>>

The Code is almost correct , slight changes will make it perfect.
 you have used ....
  <INPUT TYPE="text" Name="Addresss" Value=<%= strAddr%>>

 now use
  <INPUT TYPE="text" Name="Addresss" Value="<%= server.HTMLEncode(strAddr)%>">

Hope it helps.




Thank you Akshay. Actually, I had made a silly mistake myself, without the server.HTMLEncode() the thing will still work.

I put  
<INPUT TYPE="text" Name="Addresss" Value=<%= strAddr%>>

I tried
 <INPUT TYPE="text" Name="Addresss" Value="<%= strAddr%>">
it still work.

But your codes suggested this to me. So thank you very much for your help.


Explore More ContentExplore courses, solutions, and other research materials related to this topic.