SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Line Break

    Hi..guys! I have a textarea field which going to get value from DB while page loaded and also submit to DB while user make changing on it.

    I noticed that having some problem regarding to javascript line break while enter multiple lines in textarea.Did Javascript has any function to overcome this problem?

  2. #2
    SitePoint Addict fesh's Avatar
    Join Date
    Jan 2005
    Location
    Jackson, New Jersey
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know of any function to facilitate this need (like PHPs nl2br, for instance), but you could very easily implement this with .replace using regular expressions...but you should really try to explain your problem more...perhaps an example of the problems?
    Fesh
    imagine what it's going to be like

  3. #3
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well.Problem resolved. I am using API functions,convertLineBreakToJS(field) and convertJSLineBreak(form,field) to handle those line break problems while retrieving and submitting data.

    I integrated js with jsp.

    Code JavaScript:
    f.content.value = convertLineBreakToJS("<%=content%>"); //convert <br> to js line break

    Code JavaScript:
    convertJSLineBreak('updateForm','content'); //convert js line break to <br>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •