Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-04-2008, 04:12 AM   PM User | #1
Joseph Witchard
Regular Coder

 
Join Date: Oct 2008
Posts: 255
Thanks: 113
Thanked 0 Times in 0 Posts
Joseph Witchard is an unknown quantity at this point
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..
Joseph Witchard is offline   Reply With Quote
Old 11-04-2008, 04:15 AM   PM User | #2
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
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..
itsallkizza is offline   Reply With Quote
Old 11-04-2008, 04:34 AM   PM User | #3
Joseph Witchard
Regular Coder

 
Join Date: Oct 2008
Posts: 255
Thanks: 113
Thanked 0 Times in 0 Posts
Joseph Witchard is an unknown quantity at this point
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.
Joseph Witchard is offline   Reply With Quote
Old 11-04-2008, 04:39 AM   PM User | #4
owt200x
Regular Coder

 
Join Date: Sep 2008
Location: Oklahoma
Posts: 249
Thanks: 11
Thanked 13 Times in 13 Posts
owt200x is an unknown quantity at this point
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?
owt200x is offline   Reply With Quote
Old 11-04-2008, 04:58 AM   PM User | #5
Joseph Witchard
Regular Coder

 
Join Date: Oct 2008
Posts: 255
Thanks: 113
Thanked 0 Times in 0 Posts
Joseph Witchard is an unknown quantity at this point
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?
Joseph Witchard is offline   Reply With Quote
Old 11-04-2008, 05:44 AM   PM User | #6
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 11-04-2008, 05:28 PM   PM User | #7
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
Joseph: what was your solution? (And I apologize for not checking in all browsers before posting.)
itsallkizza is offline   Reply With Quote
Old 11-04-2008, 11:09 PM   PM User | #8
Joseph Witchard
Regular Coder

 
Join Date: Oct 2008
Posts: 255
Thanks: 113
Thanked 0 Times in 0 Posts
Joseph Witchard is an unknown quantity at this point
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
Joseph Witchard is offline   Reply With Quote
Old 11-05-2008, 03:19 AM   PM User | #9
Major Payne
Regular Coder

 
Join Date: Aug 2005
Location: MS
Posts: 745
Thanks: 7
Thanked 65 Times in 63 Posts
Major Payne is an unknown quantity at this point
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☠ ☠
Major Payne is offline   Reply With Quote
Old 11-05-2008, 07:42 AM   PM User | #10
Joseph Witchard
Regular Coder

 
Join Date: Oct 2008
Posts: 255
Thanks: 113
Thanked 0 Times in 0 Posts
Joseph Witchard is an unknown quantity at this point
All right, cool
Joseph Witchard is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:24 PM.


Advertisement
Log in to turn off these ads.