Solved

whitespace in textarea

Posted on 2006-06-29
4
881 Views
Last Modified: 2008-03-06
when I create a form it automatically inserts some whitespace, about 7 or 8 characters worth in the box,.

When I insert the $_POST data and trim it this solves the problem but how can I delete the space when the page is opened for the first time?


Ross
0
Comment
Question by:roscoeh23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Eternal_Student earned 500 total points
ID: 17008506
<form style="margin:0px; padding:0px;">

Different browsers will add different margin values if you dont declare them using css.
0
 

Expert Comment

by:CivilDisobedient
ID: 17008734
Either attach an event to the window.onload, or if you're not doing any other onload routines, put the following in your page:

<script type="text/javascript">
   document.getElementById('textAreaId').innerHTML = "";
</script>

<body>
   <textarea id="textAreaId"></textarea>
</body>

Alternatively, you could do this to *every* textarea onload with the following script substitution:

<script type="text/javascript">
   var elems = document.getElementsByTagName('textarea');
   for (var x=0, i=elems.length; x < i; x++) {
      elems[x].innerHTML = "";
   }
</script>
0
 

Expert Comment

by:CivilDisobedient
ID: 17008741
Forgot to wrap that function in the window onload handler:

<script type="text/javascript">
   window.onload = function() {

   ...code goes here...

   }
</script>
0
 
LVL 3

Expert Comment

by:zawedikian
ID: 17009099
hi
when u create ur form , check that all ur text ares are without spaces inside. If not, it wont be added when the page is opend
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

696 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