-2
I have a foreach loop that fills the screen with information from users logged in to the system, name, type and ID. implemented a button with a textfield field to send messages to system users and a button to unlock
var id = $(this).val();
The functionality of the unlock button works perfectly because you just need to grab the id and unlock the user...
As I added the textfield field and another button to send the message to the id of that user the value of that textField is not dynamic as ID.
on the line :var texto= $('#review').val();
I’ve tried applying the find the prop one each to go and nothing.
I wanted the textFild field to present me the value dynamically equal to the id field
$('.row').on('click', '#btn_text', function () {
var id = $(this).val();
var texto= $('#review').val();
const element = this;
alert(texto + id);
});
html/php code is as follows::
<div class="container-fluid">
<div class="row">
<?php
foreach ($logados as $usuarios) {
if ($usuarios['id'] != $_SESSION['user_id']){
echo '<div class="col-lg-4 col-md-3 col-sm-6 col-xs-12">
<div class="author-permissio-wrap shadow-reset">
<div class="author-per-img">
<a><img src="' . $usuarios['img'] . '" alt="" />
</a>
<div class="author-per-content">
<h2>' . $usuarios['nome_completo'] . '</h2>
<p>'. $usuarios['tipo'] .'</p>
<p><button class="btn btn-custon-four btn-primary btn-xs" id="deslogar" value="' . $usuarios['id'] . '">Destravar</button> </p>
<p class="comment-clock"><i class="fa fa-clock-o"></i>' . $usuarios['ultimo_login'] . '</p>
<textarea name="review" id="review" cols="30" rows="3" ></textarea>
<p><button type="button" class="btn btn-custon-four btn-default" id="btn_text" value="' . $usuarios['id'] . '"><span class="fa fa-comment"></span></button></p>
</div>
</div>
</div>
</div>';
}
}
?>
</div>
</div>
The attribute
id
should be unique in thehtml
and some of them will repeat in your code, such as undoing, btn_text and review.– Benilson