Daniel Burgess
Daniel Burgess

Reputation: 25

Textarea won't start at the top right every time

This textarea is one that is updated several times and each line in the textarea is for a separate entry. Thus it is better to have each starting at the very left of the textbox.


For example what i want is,


Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo.


But what it is displaying is,


_____(whitespace)_________________Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo.

This happens even though when I type in the textarea to save I do it all the way to the left. How do I get around this so that It only displays to the far left for each line?

This is my code:

                <div class="col my-2 w-1/6">
                    
                    <p class="md:text-center">Notes</p>
                    <textarea id="loc_notes" cols="30" rows="10" style = "font-size: 12px;width:100%" class="mx-1 border-2 border-black" name="location_notes">
                        @foreach($notes as $note)    
                            {{$note->my_notes}}
                        @endforeach
                    </textarea>
                </div>

Upvotes: 1

Views: 148

Answers (1)

forrestedw
forrestedw

Reputation: 395

The question is a little unclear for me but I think you want to get from this:

first entry second entry

To this:

first entry 
second entry

The way you are looping through $notes then it doesn't know that you want a carriage return after each note, to get them lining up on the left.

To get the carriage return add &#13;&#10; after each echo of the note, like this:

@foreach($notes as $note)    
    {{ $note->my_notes }} &#13;&#10;
@endforeach

See here for more details on new lines/ carriage returns in textareas.

Edit

You question is clearer now. You are getting the whitespace because of the formatting in your blade file. Change this:

<textarea>
   @foreach($notes as $note)    
        {{$note->my_notes}}
   @endforeach
</textarea>

To this (all whitespace taken out):

<textarea>@foreach($notes as $note){{ $note->my_notes }}@endforeach</textarea>

Upvotes: 0

Related Questions