Web Hosting Talk







View Full Version : TEXTAREA in form entry problem


adorno
12-19-2002, 02:03 PM
I've lately encountered a little problem in a TEXTAREA field in a form. I'm using Windows 2000 Pro, IE, ASP, VBScript, and some JScript on the client side, just in case that question comes up.

Anyhow, when I tab into a TEXTAREA field in a form, the cursor jumps into somewhere in the middle of the entry area. If I enter data starting where the cursor is positioned, the data is reflected the same way in the database record where the field is written to.
I need the cursor to position at the beginning of the field.

I have tested by first manually clearing the field, and then entering data from the beginning. Once I submit the data, the resulting "posted" info contains the entered text somwhere in the middle of the field, not at the beginning.

I've examined some of the character positions where there appears to be blanks, but, they're not blanks. If I look up the numeric position value in the ANSI table, the value is 13. I don't know how that happens or what it means. (Maybe a virus? Hope not.)

Maybe I've not clearly explained the situation, but if anyone knows of what's causing this problem, please respond.

Thanks,
E.A.

mccuem
12-19-2002, 02:17 PM
it sounds like your dynamically generating the page, including the <textarea> field... remember, anything that goes between <textarea> and </textarea> will show up in the field, likewise will be entered into the database.

ascii 13 is a carriage return, I wouldn't imagine that to come across as a space, but since there's not a newline (ascii 10) there, I guess it is possible.

Check your code for where you output the <textarea> and </textarea> tags, see if your not hitting a loop in there thats just outputting spaces or CR's.. also check for that same kind of activity before the insert.

Thats the best I can help with because I don't know the stuff your working with very well... but I can almost guarantee you this is where your problem will be.

Mike

*that's a pseudo guarantee even... no real remedies :)

PJamie
12-19-2002, 02:38 PM
That's what it is. If there's a gap between <textarea></textarea> in your code, or they are on different lines, you get the cursor appearing somewhere in the middle of the window.

adorno
12-19-2002, 03:43 PM
The 2 of you are correct and I appreciate your help.

Below is the chunk of code as it used to appear in my html code.

To correct the problem, I moved everything concerning the textarea into 1 line; it works then.

However, the new line covers 2 screens from left to right. It looks ugly. Should that be the way HTML works with TEXTAREA?Do I have any choice?

Thanks again.
E.A.
________________________________________________
<tr>
<td align=right style="color: blue; font-size: 16;">
<b>Offer Description </b>
</td>
<td bgcolor="lightYellow">&nbsp;
<textarea name="OfferDesc"
cols="50" rows="5"
onfocus="highlight('OfferDesc');"
onblur="dimlight('OfferDesc');">
<% =selOfferDescription %>
</textarea>
</td>
</tr>
_________________________________________________

mccuem
12-19-2002, 04:10 PM
put it back to the way you listed it above and put these three lines on the same line :


onblur="dimlight('OfferDesc');"><% =selOfferDescription %></textarea>


that should be fine. any other way and you'll most likely end up with CR's in your text box again.

PJamie
12-20-2002, 06:50 AM
What causes the problem is any space between to end of the opening textarea tag and the beginning of the closing textarea tag.

The other alternative being to convert the whole lot to VBScript so it writes to the page correctly. Something like this:
<%
With Response
.Write "<tr>"
.Write "<td align=right style=""color: blue; font-size: 16;"">"
.Write "<b>Offer Description </b>"
.Write "</td>"
.Write "<td bgcolor=""lightYellow"">"
.Write "<textarea name=""OfferDesc"" "
.Write "cols=""50"" rows=""5"" "
.Write "onfocus=""highlight('OfferDesc');"" "
.Write "onblur=""dimlight('OfferDesc');"">"
.Write selOfferDescription
.Write "</textarea>"
.Write "</td>"
.Write "</tr>"
End With
%>

Don't put & vbcrlf at the end of the lines and it will print correctly.

adorno
12-20-2002, 02:57 PM
Thanks for your suggestions. It works as suggested.

Apparently, the closing '</textarea>' tag cannot be on a line by itself AND indented. I tested with the closing tag on a line by itself with no indentation and the code works. If I indent the tag, the cursor ends up in the middle of the entry area, at a position equal to the number of spaces indented from the left in the code area.

Anyhow, it now works. Below is the new layout of the code area.
The 'onblur' to '</textarea> code is all on 1 line.

By the way, this forum removes blanks from the beginning of any line, therefore, my code shows up on this post with all lines
left aligned. I like pretty code and I indent all of my code for readability.


Thanks again.
E.A.

--------------------------------------------------------------------------
<tr>
<td align=right style="color: blue; font-size: 16;">
<b>Offer Description </b>
</td>
<td bgcolor="lightYellow">
<textarea name="OfferDesc" cols="50" rows="5"
onfocus="highlight('OfferDesc');"
onblur="dimlight('OfferDesc');"><% =selOfferDescription %></textarea>
</td>
</tr>
---------------------------------------------------------------------------

mccuem
12-20-2002, 04:14 PM
Wrap your code in [ code ] and [ /code ] tags (without the spaces)...

:D


<tr>
<td align=right style="color: blue; font-size: 16;">
<b>Offer Description </b>
</td>
<td bgcolor="lightYellow">
<textarea name="OfferDesc" cols="50" rows="5"
onfocus="highlight('OfferDesc');"
onblur="dimlight('OfferDesc');"><% =selOfferDescription %></textarea>
</td>
</tr>