I need help. I am doing a project and am creating a simple survey. The code I have should work. Upon pressing the "yes" button, it should add 1 to the "artscore" variable. Then when I press "submit" it should check if the variable is over 1 and if it says "You are an artist" and if it isn't bigger than 1 it should say "You are something different". However whenever I do this and press submit it always says "You are something different", even when I have clicked "yes" multiple times. It should work but it doesn't. I am a complete beginner and the answer may be very simple. I have made multiple prototypes but I want to figure out how to make a survey this way.
Thank you for any help.
BTW the HTML part of this code got taken away. This website wouldn't let me put it in. This is just the javascript part without the beginning script tag. The beginning HTML just had some buttons which when click ran the two functions. The yes button runs the artFunction function and the submit button runs the submitFunction function. I also don't know why the code below is in two parts. Thanks for any help on why this code doesn't work.
var artscore = 0;
function artFunction(){
artscore = artscore + 1;
}
function submitFunction(){
if (artscore > 1){
alert("You are an artist");
} else {
alert("You are something different");
}
}
Aucun commentaire:
Enregistrer un commentaire