Solved

whitespace in textarea

Posted on 2006-06-29
4
877 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This video teaches users how to migrate an existing Wordpress website to a new domain.

911 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

19 Experts available now in Live!

Get 1:1 Help Now