on-internet
← Community

How to save data in textarea on enter key using ajax like facebook comment?

Stack Overflow ·

I have done the code like this in view page and controller done in codeigniter. While pressing enter key multiple times data saving to the table. How can I solve this problem? View Page <form> <div class="cmt-box"> <textarea class="form-control" name="txtArea" id="txtArea<?php echo $row->id;?>" onkeypress="onTestChange(1)" rows="1"></textarea> </div></form> script function onTestChange(id) { $("#txtArea"+id).keypress(function(e) { if(e.which == 13) { dataString=document.getElementById("txtArea"+id).value; $.ajax({ type: "POST", url: "<?php echo site_url('show/insertcomment'); ?>", data: { comm

Comments

Sign in or sign up to comment and upvote.

No comments yet.