I had "solved" a problem sending a textarea by pressing Enter in my application, but it ended up only sending it to the first textarea of the page.
The application loops registered posts in the database and for each post there is an area for the user to comment on. The following code sends the contents of the first textarea by pressing enter:
$('#texto_coment').keydown(function(event) {
if (event.keyCode == 13) {
this.form.submit();
return false;
}
});
What happens is that on the page there are more than one post and I do not know how to identify each one of them.
Comment Form:
<form action="init/add_coment.php" method="post" name="enviaComent">
<input type="hidden" value="<?=$post['id']?>" name="id_post" />
<textarea id="texto_coment_<?=$post['id']?>" name="comentario" class="comentario-texto" placeholder="Escreva um comentário..."></textarea>
</form>
How can I do to press Enter to comment on a specific textarea?