Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts

    Help With Textarea Tag

    How do you set the textarea tag to where when the sentence becomes too long for the textarea, it automatically starts typing on a new line? (Like the textarea I'm typing in to make this post.)
    Last edited by Joseph Witchard; 11-04-2008 at 04:56 AM.

  • #2
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    you can use html attributes: wrap="soft" wrap="hard" wrap="off"

    hard: wraps text and includes the carriage returns in the textarea value
    soft: wraps text but doesn't add carriage returns
    off: obviously, no word wrapping

    you'll probably want to use soft

    it's odd though, iirc most browsers default to textarea word wrapping
    Last edited by itsallkizza; 11-04-2008 at 04:18 AM.

  • #3
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Is there anything else that can be done? Even using the wrap attribute, it still doesn't work in either Firefox or Opera. Only Internet Explorer I even looked up the attribute values for IE browsers and tried them instead. Nothing.

  • #4
    Regular Coder
    Join Date
    Sep 2008
    Location
    Oklahoma
    Posts
    249
    Thanks
    11
    Thanked 13 Times in 13 Posts
    opera seems to disable much code like that it even disables the body code i use to disable rightclicking and drag and drop.

    i have been using
    Code:
    wrap="PHYSICAL"
    does that even work?

  • #5
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Got it working. Thanks Just out of curiosity (I think I know what the answer will be), there doesn't happen to be any W3C standard way of doing this, is there?

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You could use javascript to set the wrapping but then again this is just going around the main issue.
    Code:
    window.onload = function()
    {
    document.forms[0].yourtextareaname.setAttribute('wrap','physical');
    }
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #7
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    Joseph: what was your solution? (And I apologize for not checking in all browsers before posting.)

  • #8
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Dang, I was hoping no one would ask It was just a stupid error on my part. When I was testing the textarea by typing in it, I just held down a key and watched whatever character I selected type as long as it could across the textarea. Then, when I was posting here, I did the same thing (I don't remember why I did so), but I saw that it did the same thing here, too. I didn't know that you had to actually be typing out words and such to get the text to wrap in the textarea. Sorry for any inconvenience I caused you guys

  • #9
    Regular Coder
    Join Date
    Aug 2005
    Location
    MS
    Posts
    845
    Thanks
    11
    Thanked 79 Times in 77 Posts

    Smile

    Might even play with another example :
    Code:
    <textarea name="Limiting Textarea Text" rows="2" cols="20" onkeyup="textLimit(this, 40);"></textarea>
    Between head tags:
    Code:
    <script type="text/javascript">
     function textLimit(field, maxlen) {
    if (field.value.length > maxlen + 1)
    alert('Your input has been truncated!');
    if (field.value.length > maxlen)
    field.value = field.value.substring(0, maxlen);
    }
    </script>
    ☠ ☠RON☠ ☠

  • #10
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    All right, cool


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •