I'm trying to make a quiz for myself and I want the data values of the selected radio buttons and the data value of them. So I can send them to a php file as an array or object.
This is my code:
let frm = $('#form');
$('input[value="finished"]').on('click', function (e) {
e.preventDefault();
console.log($('input[type=radio]:checked').data('value'));
$.ajax({
type: frm.attr('method'),
url: "ajax/quiz.php",
data: frm.serialize(),
success: function (data) {
},
}).done(function (data) {
});
});
Does anyone know why it only shows one? Because I have been searching for a while and a lot of people recommend this option.
Can't get input radio selected value
I also tried this: How to get the selected radio button’s value?
But it still shows me one data value.