my code should allow me to alternate between two values for my 'hiddenvalue' input, but despite the alert confirming that formquestion has changed to '2', when formvalue is executed again it still alerts '2' - it is not switching back and forth from the if statement to the else statement. Any ideas what i'm doing wrong?
var formquestion = 1;
function formvalue(){
if (formquestion === 1){
document.getElementById("hiddenvalue").value = "form1";
formquestion = 2;
}
else {
document.getElementById("hiddenvalue").value = "form2";
formquestion = 1;
}
alert("Value of 'formquestion' outside the function " + formquestion);
}