Javascript linebreak not working

Discussion in 'Programming' started by Site Owner, Jul 26, 2007.

  1. #1
    I found this cool script that adds text from one textarea to another. I put an example here: http://www.freewebs.com/moreauctions/addtext.html

    The problem is, I need a line break after each text is added - to make a list:

    text1
    text2
    text3

    Here is the <head> code:
    <script language="javascript" type="text/javascript">
    var linebreak = "<br />"
    function addtext() {
    var newtext = document.myform.inputtext.value;
    document.myform.outputtext.value += bullet += newtext + linebreak;
    }
      </script>
    Code (markup):
    So what am I doing wrong?
     
    Site Owner, Jul 26, 2007 IP
  2. ds316

    ds316 Peon

    Messages:
    154
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    don't use the <br /> in a text area, instead use "\r\n" as your linebreak string.
     
    ds316, Jul 26, 2007 IP
  3. Site Owner

    Site Owner Peon

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Worked :) But what if I wanted to put a bullet before each input.

    edited.
     
    Site Owner, Jul 26, 2007 IP
  4. Site Owner

    Site Owner Peon

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OK I just found out that is not possible. Thank you for your help ds316.
     
    Site Owner, Jul 26, 2007 IP