1
I had "solved" a problem of sending a textarea by pressing Enter on my application, but ended up only sending to the first textarea of the page.
The application loops posts recorded in the database and for each post has 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 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 press Enter send the comment in a specific textarea?
Thank you Paul, I will implement that yes!
– João Victor Valentim