Solved

Get rid off textarea leading spaces

Posted on 2007-03-23
15
571 Views
Last Modified: 2008-01-09
I am having a nightmare with HTML textarea tag.  No matter what i do it will put spaces before the cursor.  so when i tab to an empty textarea the cursor will go a few spaces to the right.  I have seen many solutions here at EE I tried those applicable (take all spaces off, unindent everything)  I ended up with this --- everything in one line -- yet the problem is still there.

<tr><td >&#160;</td><td valign="top"><font style="FONT-SIZE: 9pt; COLOR: 417D41;  FONT-FAMILY: Arial">Comments:</font></td><td><textarea name="comments" rows="3" cols="5" value="" ID="Text142" style="width: 400px; border: 1 solid #8CC38C; color:4C854C;"></textarea></td><td >&#160;</td></tr>

Where the clever clogs?  help please
0
Comment
Question by:gbzhhu
  • 7
  • 7
15 Comments
 
LVL 5

Expert Comment

by:rucky544
ID: 18781183
textarea shouldn't have a value property, can't see anything else wrong with it though!?!
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 18781236
Removed the value property but no luck :-(  still the same.  Strange enough I have another page that had the same problem but got fixed when I took indentation off the code.  This is IE but I just tried FireFox.  The same result!!
0
 
LVL 29

Expert Comment

by:Badotz
ID: 18781323
>> problem but got fixed when I took indentation off the code

Could you clarify, please?
0
 
LVL 5

Expert Comment

by:rucky544
ID: 18781351
can you delete the space that it puts in at the start?

have you got any javascript or CSS that is working on id="Text142" or textarea?

The actual textarea code is fine... it must be something else effecting it!
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 18781396
Badotz:

In another page, I had another textarea tag.  Initially it was behaving the same as the one I posted the question for.  That is when I tab to the empty textarea, the cursor was  going a few spaces to the right (not at the beginning) this causing leading spaces.  My code was indented example below
<tr>
   <td>
          <textarea name="BBB" etc></textarea>
   </td>
</tr>

I remove the indentation

<tr>
<td>
<textarea name="BBB" etc></textarea>
</td>
</tr>

and it worked

BUT it doesn't work for this particular textarea.  Weird!!
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 18781438
rucky544:

Yes, I can delete the spaces

I have a javascript that puts a particular (named) textarea some values.  I renamed my textarea to commentsxx and the ID to id="Text142XX".  It made no difference.

The following javascript removes the spaces but it is only a workaround.  I wanted to find the reason and fix it.

I must reboot my PC!!  Fixes most problems!!!
 onFocus="javascript:while(''+this.value.charAt(0)==' ')this.value=this.value.substring(1,this.value.length);"
0
 
LVL 5

Expert Comment

by:rucky544
ID: 18781443
there is no reason why that alone would work?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 5

Expert Comment

by:rucky544
ID: 18781475
can you put the page up for us to see? It sounds like JS is adding in some spaces for some reason. Because it isn't the HTML and can't be CSS if it is putting actual spaces in there.
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 18781483
>>there is no reason why that alone would work?
which one?
0
 
LVL 5

Expert Comment

by:rucky544
ID: 18781501
sorry i meant the indentation. takeing indentation out of the code wouldn't make any difference unless maybe it was like

<tr>
   <td>
          <textarea name="BBB" etc>
          </textarea>
   </td>
</tr>

Then it might have put extra spaces in at the beginning of the textarea.
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 18781573
rucky544:

I can't remember whether the ckosing textarea tag was on the same line or not
0
 
LVL 5

Accepted Solution

by:
rucky544 earned 500 total points
ID: 18781584
try turning JS off in your browser and then test the page.
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 18781587
The site is commercial and will need logging in therefore I cannot put the page up but I can post the output here if it helps.

Also I am not using CSS.
0
 
LVL 12

Author Comment

by:gbzhhu
ID: 18781654
ARRRGHHHH!!!

Ok, calm down.  On trying to do what rucky544:said (turn of JS) I opened a new browser screen, relogged in to the site and run the page. NO PROBLEM!!!  Bloody browser must have been caching stuff.  Now I even refreshed the older browser screen and it works there too.  That is why i said I should restart PC which i didn't.

Thank you all so much.  Points go to rucky544:
0
 
LVL 5

Expert Comment

by:rucky544
ID: 18781668
glad you got it sorted in the end....
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

709 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now