开发者

jQuery (or other) multiple choice quiz with different outcomes

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.


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;');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜