Forum Discussion
Selecting random items from a list and displaying the selected items alone in order
Try this sample. Once the variables are set to True or False, the JS sorts them and places them on the second page. Variables that are blank don't show on the second page. If you need more explanation, please ask.
- BradleyEader-6b3 years agoCommunity Member
Hi and thank you for getting this started Walt! There was one issue I found with the javascript, so to get it working the == "true" part needed to have the quotes removed: var player = GetPlayer();
var correct =[];
var inCorrect =[];
var selections =[];
var j=1;
var k=1;
var NOP = ["", "Jaw Thrust maneuver", "Oropharyngeal airway", "Nasopharyngeal airway", "King (multi-lumen) airway", "Laryngeal Mask Airway (LMA)", "Endotracheal tube", "Cricothyroidotomy"];
selections[1] = player.GetVar("JawThrust");
selections[2] = player.GetVar("Oro");
selections[3] = player.GetVar("Naso");
selections[4] = player.GetVar("King");
selections[5] = player.GetVar("LMA");
selections[6] = player.GetVar("ET_Tube");
selections[7] = player.GetVar("Crico");
for(i = 1; i < 8; i++){
if (selections[i] == true) {
correct[j] = NOP [i];
j++;
} else {
inCorrect[k] = NOP[i];
k++;
}
}
for(i = 1; i < 8; i++){
if (correct[i] != null) {player.SetVar("Correct" + i, correct[i]);}
if (inCorrect[i] != null) {player.SetVar("Incorrect" + i, inCorrect[i]);}
}