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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format string using javascript.

Status
Not open for further replies.

malaygal

IS-IT--Management
Joined
Feb 22, 2006
Messages
192
Location
US
I am trying to retrieve and format some data coming from an Oracle table. The data type of the field is varchar2(200), and it gets updated by our user who enter text on a text area.
The textarea does not have any max limit such that user can enter paragraphs, complete with tabs. When the field is updated, user is actually updating multiple rows with new line field as the 200th char of the field,
I want to be able to retrieve these rows and format them the way user typed in on the textarea by passing the recordset to a javascript and passing back a formatted string:
When I do this,

While Not rs.EOF
%>
<td><%=rs("comments")%></td>

<%
end if
rs.MoveNext
WEnd

The text did not flow naturally, words are being cut-off and the tab(indents) are missing.
Something like this:

The order are shipped on time. .................. The quality of th (199 char + nl feed)
e merchandise superb.
I will definitely place another order on line. (this should have been intended)

I would want to pass all the rows retrieved to a js function and have the function reurn a formatted string.

Any help will be greatly appreciated.


 
Let us know what you have tried, and what did/didn't work.

You have put forward some requirements... let us know when you have attempted to implement them - and if you get stuck then ask some specific questions (to solve the specific problem).

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
maylaygal,
You apparently are using ASP to pull your data from the database. You need to then use ASP to parse the data seeking out carriage returns, line feeds and tab characters and substituting them with equivalents that will be rendered in the HTML page. For instance replace carriage returns with <br>. If you find single quotes in the string you need to escape them.


Stamp out, eliminate and abolish redundancy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top