1
Good morning my doubt and complex this creating a system that will create card of each registered user, to differentiate the card each element of the card has the user id. I would like to know how I capture the value of the selected radio, but the name of the radio is concatenated with the user id to be able to differentiate from the other card.
Check out the code :
THIS CREATES THE CARD
while ($registro = mysqli_fetch_array($resultado_id, MYSQLI_ASSOC)) {
echo '<div class=" cardUser col-md-12">
<div class="cardNome">
<span>'.$registro['nome'].'</span>
</div>
<div class="cardPro">
<span class="glyphicon glyphicon-education"> '.$registro['idProfissao'].'</span>
<span class="cardPro2 glyphicon glyphicon-education"> '.$registro['idProfissao2'].'</span>
</div>
<div class="cardInfo">
<ul class="cardUl">
<li class="cardLi">
<span class="cardValue glyphicon glyphicon-globe"> '.$registro['idCidade'].'</span>
<span class="cardValue glyphicon glyphicon-earphone" id="tel"> '.$registro['telefone'].'</span>
</li>
</ul>
<div class="estrelas">
<ul class="cardUl">
<li class="cardLi">
<span class="cardLabel">Status:</span>
<span class="cardValue"> '.$registro['disponibilidade'].'</span>
</li>
<li class="cardLi">
<Form id="estrelas">
<span class="cardLabel">Avaliação:</span>
<input type="radio" id="cm_star-empty-'.$registro['id'].'" name="fb'.$registro['id'].'" value="" checked/>
<label for="cm_star-1-'.$registro['id'].'"><i class="fa"></i></label>
<input type="radio" id="cm_star-1-'.$registro['id'].'" name="fb'.$registro['id'].'" value="1"/>
<label for="cm_star-2-'.$registro['id'].'"><i class="fa"></i></label>
<input type="radio" id="cm_star-2-'.$registro['id'].'" name="fb'.$registro['id'].'" value="2"/>
<label for="cm_star-3-'.$registro['id'].'"><i class="fa"></i></label>
<input type="radio" id="cm_star-3-'.$registro['id'].'" name="fb'.$registro['id'].'" value="3"/>
<label for="cm_star-4-'.$registro['id'].'"><i class="fa"></i></label>
<input type="radio" id="cm_star-4-'.$registro['id'].'" name="fb'.$registro['id'].'" value="4"/>
<label for="cm_star-5-'.$registro['id'].'"><i class="fa"></i></label>
<input type="radio" id="cm_star-5-'.$registro['id'].'" name="fb'.$registro['id'].'" value="5"/>
</Form>
</li>
<button type="button" class="btn btn-info btn-sm btn-like" id="btn-like-'.$registro['id'].'" data-id_usuario="'.$registro['id'].'">Avaliar</button>
</ul>
</div>
</div>
</div>
';
}
This is js code that I use to send the variaves user id I can capture more radio value I don’t know how to do.
<script type="text/javascript">
$(document).ready( function () {
$('.btn-like').click(function(){
var id_usuario = $(this).data('id_usuario');
var estrela = $(this).data('');
$('#btn-like-'+id_usuario).hide();
$.ajax({
url: 'like.php',
method: 'post',
data: { like_id_usuario: id_usuario, },
success:function (data) {
alert('Registro realizado com sucesso');
}
});
});
})
</script>
Good afternoon Sérgio I appreciate your willingness to help me, in the example you used the button id to capture the information. More how do I do this with radio where the name is used to pass the value? Like my radio has the name=fb(+id of the user recovered in select) it has this name to differentiate one card from the other to be able to manipulate a radio without affecting the other card. How do I for this context know inform me. If it can be as didactic as possible thank you post I am new in the area.
– Mayke Alisson
@Maykealisson can clarify which button you click and which
radio
Want to extract the value? You want both the user ID and the value ofradio
?– Sergio
I managed to make it work thanks.
– Mayke Alisson