You could use a preincrement operator as opposed to a postincrement operator. The difference is one returns the incremented value the other returns the current value and then increments it.
if (++count == 1) { // it's equal to 1
// do button stuff here
}
So the code so far displays a form with multiple radio buttons, followed by a submit button that uses an onclick function called check(). The check() function checks if the first radio button is selected, and if so, adds a value of +1 to the variable count which then triggers an alert that shows the value of the variable count. What i want to do next is to create an if statement that checks if the value of the variable count is equal to 1 and if so display a button that acts as a link to another page. I have tried making my own if function that does that, but it conflicts with the first if statement in a way that both of the if statements do not work. How would i achieve the second if statement successfully?
<section id=Box>
<form name="Question">
Q1. Le groupe sanguin O négatif peut donner à quel autre groupe sanguin ou groupes sanguins?<br><br>
<input type="radio" name="q1" value="a">AB-, A-, B-, et O-</br>
<input type="radio" name="q1" value="b">O+ et O-</br>
<input type="radio" name="q1" value="c">A+, A-, B+ et B-</br>
<input type="radio" name="q1" value="d">Tous les groupes sanguins</br><br>
<button type="button" value="submit" onclick="check()"># de Réponses correctes</button>
</form>
</section>
<script type="text/javascript">
function check(){
var q1 = document.Question.q1.value;
var count= 0;
if(q1=="a"){
count++;
}
alert("vous avez "+count+" réponse(s) correcte(s)!");
}