Page 1 of 1

Word spacing

Posted: Sun Sep 26, 2004 2:27 pm
by [n00b]
How can make text in a cell that has no spacing to be automatically "wrapped"?
I`m writing a shoutbox script for my site that will appear on a box like 140 or 150 px long. The problem is, when a user writes a word that has length more than the cell can fit (like "this_is_a_long_word_and_it_does_not_fit_in_the_cell" or "aaaaaaaaaaaaaaaaaaaaaaaa") the cell gets stretched messing all the other cells and tables. So, how can make that cell wrap text so text like this:
this_is_a_long_word_and_it_does_not_fit_in_the_cell
appears like this:
this_is_a_long_word_and
_it_does_not_fit_in_the_cell

Thanks :)

Posted: Sun Sep 26, 2004 2:50 pm
by feyd
searching the manual should have turned up: [php_man]wordwrap[/php_man] :roll:

Posted: Sun Sep 26, 2004 2:55 pm
by [n00b]
isnt this possible in HTML? :roll:

Posted: Sun Sep 26, 2004 2:58 pm
by feyd
not anymore. used to be able to use the <wbr> tag, but that doesn't exist anymore.

you can use CSS overflow attribute potentially.

Posted: Mon Oct 04, 2004 9:02 am
by no_memories
I think u need a java script, which is used in this forum software of all things.

Code: Select all

//http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close) &#123;
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2) 
	selEnd = selLength;
	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
&#125;
Not sure if this is the entire piece of code required, but the mozedit script can be purchased at the website in the code for around 2 bucks U.S. - providing you want the word wrap that bad on your textareas. :)