function ajax_value_save(id) {
if (document.getElementById('a').checked) {
var rate_value = document.getElementById('a').value;
} else if (document.getElementById('b').checked) {
var rate_value = document.getElementById('b').value;
} else if (document.getElementById('c').checked) {
var rate_value = document.getElementById('c').value;
} else if (document.getElementById('d').checked) {
var rate_value = document.getElementById('d').value;
}
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var result1 = document.getElementById('val1');
result1.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open('GET', 'answersave.php?valsave=' + rate_value + '&qid=' + id, true);
xmlhttp.send();
}
if(!empty($_REQUEST['valsave'])){
$valsave = $_REQUEST['valsave'];
$id = $_REQUEST['qid'];
}
array_push($_SESSION['answers'], $valsave);
array_push($_SESSION['quid'], $id);
If I select the correct answer it's okay, but if sometimes I try to select one after the other radio buttons more than one answer gets stored. The thing is if there are four multiple-choice and I choose the right one it's fine but if I continue selecting more than one and submit the answer more than one answer gets stored.