1

I've been coding jQuery for a while but I have never approached a quiz before.

Basically, I am trying to make a quiz like the multiple choice ones you get as a kid - if you've answered majority A, you get a certain outcome, but if you are majority B you get a different outcome etc...

Could anyone point me in the right direction of how to do this? Because so far I've only encountered tutorials that show you how to assign a value to a checkbox and then calculate a numerical answer. However, I can't figure out how to apply this to non-numerical id's.

Thanks in advance.

dan1st
  • 12,568
  • 8
  • 34
  • 67
user783440
  • 21
  • 3

1 Answers1

1

You can always use Java Script to assign to arbitrary properties of an appropriately named variable.

var answers = {
    a: 0,
    b: 0,
    c: 0
};

function answer(answer){
    exec('answers.' answer.toLowerCase() + ' += 1;');
}
Kyle Sletten
  • 5,365
  • 2
  • 26
  • 39
  • 1
    A quiz with this format: http://www.blogthings.com/whatcolorcrayonareyouquiz/ So you choose answers from the multiple choice questions and then depending on if you've answered majority A, B, C etc, you get a specific answer. – user783440 Jun 04 '11 at 00:31