I'd be seriously tempted to reorganize this.
Will the answer for "closest match" (to the 3 answers) be coming from a DB query? That is, using AJAX or similar? Or will you hard code the matches in the JavaScript?
If you are going to hard cold the matches, I'd be tempted to do it thus:
Code:
var choices = {
"sour" : {
"cold" : {
"good" : "diet limeade",
"bad" : "sour lemon slushee"
},
"warm" : {
"good" : "fresh sour cherries",
"bad" : "sour lemon candies"
}
"hot" : {
"good" : "hot and sour soup",
"bad" : "chili relleno"
},
"burning" : {
"good" : "fresh jalapeno pepper",
"bad" : "fresh jalapeno pepper" /*joke*/
}
"bland" : {
"cold" : {
"good" : ... etc ...
You see that? Then to find the product you only have to do:
Code:
var product = choices[userTasteChoice][userTempChoice][userGoodBadChoice];
But clearly that could get tedious for lots of choices, so I'd hope you are really going to do this via a DB and AJAX?