I have a textarea
and I am also writing some PHP code to prefill the textarea
upon refresh. The "prefill" part is working fine.
My problem is when I start to type in the textarea
, the text is not left aligned. It is starting at some random point in the textarea
box. I want it left aligned like a normal text box.
Here is my code:
<TEXTAREA rows = 10 cols = 95 name = answer5>
<?php echo stripslashes(htmlentities($_POST['answer5'])); ?>
</TEXTAREA>
Trimming is not a best option to go with.
It will trim all the spaces which are even needed. I had the same problem and what I did was made all the code in a single line.
It depends on the spaces which you have in your text. My code was sometime like this before
<div class="controls">
<textarea name="about" class="span12" id="terms" rows="5">
<?php include('includes/terms.php');?>
</textarea>
</div>
Now output which I was getting was like this:
Terms and Conditions
Point one
Point two
Point 3
Last Paragraph
// Here was huge space right at the bottom of textbox
So what is did was, modified my code this way:
<div class="controls"><textarea name="about" class="span12" id="terms" rows="5"><?php include('includes/terms.php');?></textarea></div>
Now everything is in single line and the spaces and new line entries which were there before are now gone. My text was printed like:
Terms and Conditions
Point one
Point two
Point 3
Last Paragraph
// Huge space is gone
You should also check the spaces which are there in the text contained in textarea element, apart from starting and ending points.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With