[RESOLVED] textarea truncate to fit width
In my site I have an area where users can send messages to other users that has the username of the person they are sending it too automatically entered into the textarea used for the messages followed by a space and a dash and then another space and then I want the user to be able to enter their message after that so it appears something like this:-
username - users message goes here bllah blah blah blah blah
What I want though is for the message to be truncated in a certain way. The problem I have is this if the user enters the following:-
The 'w's go onto a whole new line once they exceed the width of the text area whereas I want it to actually do this:-
username - wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
Similar to the way twitter truncates their entries, if truncate is the right word for it.
How can this be done?
echo wordwrap($longword, 80, "\n", TRUE);
Hi Rahim. Thanks for the reply. That looks good but I need it to work on the fly i.e. as the user is actually entering text. Will that work as the user is entering text into a textarea?
In short, no it wont. The text field is tried to the browser (actually more to the the operating system than the browser), so it's going to behave the way the OS works.
Originally Posted by jimmyoneshot
Thanks october wind. I know what you mean now. After looking more closely it seems that Twitter also does it the way I posted above i.e. the www... would go onto a new line rather than truncating.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)