I know this question was before already, but I do not know how to solve it in my case.
This is code whioch I'm using for submit the data.
$status_ui = '<textarea id="statustext" style="max-width: 85%;" class="form-control" rows="3" onkeyup="statusMax(this,250)" placeholder="What's new with you ' . $u . '?"></textarea>';
$status_ui .= '<button id="statusBtn" style="height:84px;width:15%;" type="button" class="btn btn-default" onclick="postToStatus(\'status_post\',\'a\',\'' . $u . '\',\'statustext\')">POST</button>';
How I can convert this code into one line with and by pressing Enter it will do exactly as before when I pressing POST
This is sample which I found, but do not know how exactly implement it in my situation.
http://jsfiddle.net/McH8q/28/
<script>
$('#textarea').on('keydown', function(event) {
if (event.keyCode == 13) { /* <-- This is your enter button keycode here */
if (!event.shiftKey) {
$('#testForm').submit(); /* allows for you to skip line in text area */
}
}
});
$('#textarea').keydown(function(e) {
if(e.which == 13) {
postToStatus(\'status_post\',\'a\',\'' . $u . '\',\'statustext\');
}
});
</script>
Something like this or how??