Need Help on HTML and JavaScript

Discussion in 'JavaScript' started by kks_krishna, Nov 4, 2007.

  1. #1
    HI,

    I am adding comments to my site. When user enerting the comments, it should be add in the same format how he has entered in the textbox. But, everything coming in the same line. Can anyone help me on this?
     
    kks_krishna, Nov 4, 2007 IP
  2. goliathus

    goliathus Peon

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think it's not HTML or JS problem, but you should use NL2BR ( $newstring = nl2br($string); ) function in PHP (or similar in ASP, etc...). Then you will get what you need ..
     
    goliathus, Nov 4, 2007 IP
  3. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Please can you provide me any related links for that
     
    kks_krishna, Nov 4, 2007 IP
  4. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How are you posting the content?

    just do this: COMMENT.replace("\n", "<br />")
     
    MMJ, Nov 4, 2007 IP
  5. goliathus

    goliathus Peon

    Messages:
    93
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I don't think so it is problem of JS. The comments must be saved anywhere, and I don't think so it's fully managed by JS. So the best was is replace it in PHp or ASP, I dunno which language do you use.

    If PHP, read this: php.net/manual/en/function.nl2br.php

    If it is really problem of JS, use the code from MMJ
     
    goliathus, Nov 4, 2007 IP