0

I have a textarea

 <textarea name="a" id="a" onkeyup="gh(event);" cols="30" rows="1"></textarea>

and im using it to transfer text into my server but just like facebook comment box there is no submit button data submits when user presses Enter and when users presses Shift+Enter they are allow to create to new line here is my JS Function

function yh(e) {
  if(e.keyCode)
  {
    unicode = e.keyCode;
  }
  else
  {
    unicode = e.charCode;
  }
  if (e.keyCode == 13 && e.shiftKey)
  {
    return false;
  }
  else if(e.keyCode == 13 )
  {
    //do submit 
  }
}

but when i submit the data and then fetch it then the new line doesnot appearing i have used str_replace("\n","<br/>","$data") and nl2br($data) function of PHP but they are not working can you tell me where is the problem??

KeyNone
  • 8,745
  • 4
  • 34
  • 51
Null
  • 154
  • 1
  • 14
  • Var dump your content and look for line breaks – scrowler Dec 13 '13 at 19:56
  • Are you using any editor, such as tinymce, that would strip these out, or any other processes that would be removing the new line? – jtlowe Dec 13 '13 at 19:57
  • gh is being called onkeyup by the textarea but your function is named yh. Other than that, this may be similar to http://stackoverflow.com/questions/7981786/line-breaks-in-textarea-element – Joshua Walcher Dec 13 '13 at 19:57
  • i am using sublime 2 @jtlowe – Null Dec 13 '13 at 20:07
  • Are you able to see the new lines in your database? Are you sure the text is making it to the database with new line characters? This might narrow down where the problem is. – jtlowe Dec 13 '13 at 20:43
  • @jtlowe no str_replace is not working so there is no
    in databases!
    – Null Dec 14 '13 at 06:13

0 Answers0