Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. idiot question...

idiot question...

Scheduled Pinned Locked Moved Web Development
questionjavascriptcom
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    l a u r e n
    wrote on last edited by
    #1

    heh im trying to replace \r\n (newlines in a text area) with
    tags for a preview window and im going slightly mad can anybody tell me what magic javascript incantation i should use in the: dtext = text.replace("\r\n","<br>"); line? thnx :suss:


    "there is no spoon"
    biz stuff   about me

    A 1 Reply Last reply
    0
    • L l a u r e n

      heh im trying to replace \r\n (newlines in a text area) with
      tags for a preview window and im going slightly mad can anybody tell me what magic javascript incantation i should use in the: dtext = text.replace("\r\n","<br>"); line? thnx :suss:


      "there is no spoon"
      biz stuff   about me

      A Offline
      A Offline
      allia
      wrote on last edited by
      #2

      try using dtext = text.replace("\r\n","\n"); or use dtext = text.replace(/\r|\n|\r\n/g, ""); I live to code.

      L 2 Replies Last reply
      0
      • A allia

        try using dtext = text.replace("\r\n","\n"); or use dtext = text.replace(/\r|\n|\r\n/g, ""); I live to code.

        L Offline
        L Offline
        l a u r e n
        wrote on last edited by
        #3

        i tried both and neither worked im basically throeing up a new window that is supposed to show an html preview of what is typed into a textarea ... when the user hits the enter key a \r\n sequence is generated (i thought) and i need to replace that with <br> for formatting purposes thnx for trying tho


        "there is no spoon"
        biz stuff   about me

        1 Reply Last reply
        0
        • A allia

          try using dtext = text.replace("\r\n","\n"); or use dtext = text.replace(/\r|\n|\r\n/g, ""); I live to code.

          L Offline
          L Offline
          l a u r e n
          wrote on last edited by
          #4

          sorry my bad it worked after i understood what u actually said to me :)


          "there is no spoon"
          biz stuff   about me

          A 1 Reply Last reply
          0
          • L l a u r e n

            sorry my bad it worked after i understood what u actually said to me :)


            "there is no spoon"
            biz stuff   about me

            A Offline
            A Offline
            allia
            wrote on last edited by
            #5

            glad to have helped ;) I live to code.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups