I am beginner and trying to make a dynamic quiz using ajax, I want to change the color of question number navigation when the radio button is checked and when I click on the Next button, the Background color should be green.
Here is the code
<script type="text/javascript">
function load_previous(){
if(questionno=="1"){
load_questions(questionno);
}else{
questionno=eval(questionno)-1;
load_questions(questionno);
}
}
function load_next(){
questionno=eval(questionno)+1;
load_questions(questionno);
<!------------------change ------bgcolor-------question number navigation------------------>
if(document.getElementById('r1').checked) {
document.getElementById("quest-number").style.backgroundColor = 'Green';
document.getElementById("quest-number").style.color = 'white';
}else if(document.getElementById('gender_Female').checked) {
document.getElementById("r1").style.backgroundColor = 'gray';
document.getElementById("quest-number").style.color = 'black';
}
}
</script>
<!------------------------SAVE----ANSWER---------------------->
<script>
function radioclick(radiovalue, questionno){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
}
};
xmlhttp.open("GET", "ajax/save_answer_in_session.php?questionno="+ questionno + "&value1=" + radiovalue, true);
xmlhttp.send(null);
}
</script>