Forum Moderators: open
how to read the contents of a text area line by line,
when the text entered with a enter key and several lines are visible in the text field.
But when submitting, it comes as single string separated by spaces.
But i need to get the test field line by line.
thanks
rsennat
when using CGI Dump, for the text area, i could see that it is displayed as viewed in browser.
but when i store the value of the text area in a variable and print it, its a single string.
i need the text area to be in the string line by line. (may be array of string would be fine)
how do i get this done?
thanks
rsennat
and how to check the \n or \r
please help me to sort it out.
thanks
rsennat
I think what you're asking has to be done with Javascript or something. When someone types and the text approaches the right margin of the box, the browser wraps it around but when submitted it still remains a single line UNLESS the user enters returns. If they do, the newlines are maintained.
So if you write some Javascript that reads the text field on each keystroke and maintains track of the current line, when each line reaches n characters it adds a \n. That could work, but keeping it consistent across all browsers will be a trick. :-D
Server-side is easy, in the language of your choice you just split on the newlines, tossing away the elements that are blank.
wrap="hard" (alternative values: "soft" and "off") was invented by Netscape IIRC but only adopted by Microsoft [msdn.microsoft.com]: hard: Text is displayed with wordwrapping and submitted with soft returns and line feeds.
It will work in IE only and was not adopted as a standard in HTML 4.0, so unless your project is for an intranet you cannot really depend on this attribute.