I have a JS code that when I select one of the 2 radio inputs of a form, it returns me if the question is correct or incorrect. I need to please know how to select the radio click where you click on the div because when I click on the div it only changes the color but it does not leave the selected radio.
The code is as follows
JS:
$("#listado li ul li div").click(function(){
if($(this).attr('class')=='correcto seleccionado'){ /*si acierta*/
$(this).removeClass().addClass('acertado_usuario');
$(this).siblings('.normal').removeClass().addClass('resto');
}
else if($(this).attr('class') == 'normal seleccionado') { /*si no acierta*/
$(this).removeClass().addClass('fallado');
$(this).siblings('.normal').removeClass().addClass('resto');
$(this).siblings('.correcto').removeClass().addClass('acertado');
}
$(this).attr("disabled", true);
$(this).siblings().attr("disabled", true);
$(this).css('cursor', 'default');
$(this).siblings().css('cursor', 'default');
correctas = $('.acertado_usuario').size();
falladas = $('.fallado').size();
no_answer = $('.correcto').size();
nota = ((correctas - (falladas /(4-1)))/total) * 10;
nota4 = ((correctas / total) - (falladas /(4 * total))) * 10;
$("#resultado_a").html("Correctas: "+correctas);
$("#resultado_b").html("Incorrectas: "+falladas);
$("#resultado_c").html("Sin respuesta: "+no_answer);
$("#resultado_d").html("Nota: "+nota.toFixed(2));
});
And the form contains the following radios:
<div class="correcto"><input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer1'];?></div>
<div class="normal"><input type="radio" value="2" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'/> <?php echo $result['answer2'];?></div>