Textarea and Breakline

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • imarkdesigns
    New Member
    • Jul 2007
    • 46

    Textarea and Breakline

    Hi,
    just want to know how can i possibly do having a breakline while typing inside the textarea box.. um, just like doing in blog page... so you can put break lines or paragraph.? sorry i cant exactly figure out the problem, but i hope you got the idea in typing paragraph in textarea in a blog page. i guess this is some kind of a javascript language...
  • MarkoKlacar
    Recognized Expert Contributor
    • Aug 2007
    • 296

    #2
    Hi,

    let me just make sure I got the problem right, you want to write something in a textbox and have the formatting, in this case breakline, correct?

    Just like you assumed my guess is you need some javascript textbox that preserves formatting, don't think you can control this using php unfortunately.

    Try posting in the javascript forum.

    Cheers.

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      once key in the ENTER key if you want to start with a new line you can use nl2br(). see the sample here. but I think you may better to use a advance editor.

      [code=html]
      <html>
      <head>
      </head>

      <body>
      <form action="line_br akes_in_text_ar eas_.php" method="post">
      <textarea name="txt_nl2br " rows="" id="txt_nl2br"> </textarea>
      <input name="nl2br" type="submit" id="nl2br" value="nl2br" />
      <br />
      <textarea name="txt_norma l" rows="" id="txt_normal" ></textarea>
      <input name="Normal" type="submit" id="Normal" value="Normal" />
      <br />
      </form>
      </body>
      </html>[/code]

      [code=php]
      <?php
      if(isset($_POST['nl2br'])){
      echo nl2br($_POST['txt_nl2br']);
      }
      if(isset($_POST['Normal'])){
      echo $_POST['txt_normal'];
      }
      ?>
      [/code]

      Comment

      • imarkdesigns
        New Member
        • Jul 2007
        • 46

        #4
        Originally posted by ajaxrand
        once key in the ENTER key if you want to start with a new line you can use nl2br(). see the sample here. but I think you may better to use a advance editor.

        [code=html]
        <html>
        <head>
        </head>

        <body>
        <form action="line_br akes_in_text_ar eas_.php" method="post">
        <textarea name="txt_nl2br " rows="" id="txt_nl2br"> </textarea>
        <input name="nl2br" type="submit" id="nl2br" value="nl2br" />
        <br />
        <textarea name="txt_norma l" rows="" id="txt_normal" ></textarea>
        <input name="Normal" type="submit" id="Normal" value="Normal" />
        <br />
        </form>
        </body>
        </html>[/code]

        [code=php]
        <?php
        if(isset($_POST['nl2br'])){
        echo nl2br($_POST['txt_nl2br']);
        }
        if(isset($_POST['Normal'])){
        echo $_POST['txt_normal'];
        }
        ?>
        [/code]
        interesting and it works perfectly...

        thank you very much for your help! i appreciate it. :)

        Comment

        • ak1dnar
          Recognized Expert Top Contributor
          • Jan 2007
          • 1584

          #5
          Originally posted by imarkdesigns
          interesting and it works perfectly...

          thank you very much for your help! i appreciate it. :)
          Welcome! and if you ever need anything post back to the forum. good luck.

          Comment

          Working...