Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textare + firefox = Text does not wrap even if using wrap = hard 1

Status
Not open for further replies.

josel

Programmer
Oct 16, 2001
716
US
Howdy!

While writing an application I found that my FireFox browser does not wrap text when it reaches end of text area. A horizontal scroll bar is display and text simply keeps on going.

Ironically, this very site does not have the problem? Where do I get the code? :)

I would love to find a solution to this. Particularly, split the text by adding a hard return (same as user press ENTER key). I would like that because on a previous post I learned how to take the content from a textare field and place it into an array.

Is there a solution to this? I have searched the and low and cannot find a thing. I found posts describing same problem dating back several years but no solution.

Regards,

Jose Lerebours

KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
I suspect that you are not included spaces in your textarea. try using commas to delimit columns and double quotes to contain values. then including the odd space after the comma will not matter.

even better, have the user upload a csv file instead. i have posted csv to db code on the forum a number of times and there are also good examples in the manual.
 
I think you could do it with a Javascript function that would add a space after a certain number of spaceless characters are typed.
 
Something to start with (with JS):

Code:
var chars_after_space = 0;

function form_input_wrapforce( limit , obj ) {

    if (obj.value.lastIndexOf(' ') == (obj.value.length - 1)) {
    
    chars_after_space = 0;
    
    } else {
    
    chars_after_space++;
    
    }

    if ( chars_after_space > limit ) {
    
    obj.value = obj.value + " ";
    chars_after_space = 0;
    
    }
    
}

Code:
<textarea onkeydown=\"return form_input_wrapforce(24, this)\" ...
 
Sleidia,

What a great script :) :) :)

I changed the parameter from 24 to 76 and it now makes sure that all content typed fits within my defined cols=77

It works exactly like tek-tips does !!!

Thanks so very much ...

Regards,


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Thanks for the compliment :)

But I think that the function should be improved in order to take into account the possibility of junk paste in the textarea.

Lastly, you will need to have a server-side version of the function just in case JS is disabled.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top