?
Solved

whitespace in textarea

Posted on 2006-06-29
4
Medium Priority
?
882 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 2000 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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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