# Multi Answer Question? Help appreciated!

**URL:** <https://forum.kirupa.com/t/multi-answer-question-help-appreciated/167236>\
**Category:** flash\
**Created:** [October 26, 2005, 2:57pm UTC](https://forum.kirupa.com/t/multi-answer-question-help-appreciated/167236 "2005-10-26T14:57:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![101\_North](https://avatars.discourse-cdn.com/v4/letter/1/58956e/32.png) [@101\_North](https://forum.kirupa.com/u/101_North)\
**Post date:** [October 26, 2005, 2:57pm UTC](https://forum.kirupa.com/t/multi-answer-question-help-appreciated/167236/1 "2005-10-26T14:57:16Z")

</div>

I’m hoping someone out there knows more about Flash than me :crying:

I’m trying to write a multiple answer question for a project I’m working on. From a list there is more than 1 correct answer. I hadn’t got a clue where to start so I started by looking at the tutorial for a creating a form using components.

My thinking is that if I can harness the values for the checkboxes the user selects then I can (??) compare them to a variable for the correct answer and base my feedback on this.

I am basing the code below on 5 checkboxes with instance names A-E. I have one reset button and one submit button.

With me so far…Here’s my code:

[color=black]correctAnswer = [B,C,E]; [color=red]// just an example[/color] [/color]  
[color=red][/color]  
[color=red]// define my checkbox instance names[/color]  
myCheck = [A,B,C,D,E];  
myCheck.sort();

[color=red]// record what’s selected[/color]  
function checkDisplay(component) {  
var options,ticked;  
for(options in myCheck){  
if(myCheck[options].getValue()) ticked += myCheck[options].getLabel();  
}

[color=red]// set a variable to contain what was selected[/color]  
myAnswer = ((ticked.length) ? ticked : “”);  
myAnswer.sort();  
}

[color=red]// the usual…(whatever that means)[/color]  
for (i=0;i\<myCheck.length;i++) {  
myCheck\*.setChangeHandler (“checkDisplay”);  
}

[color=red]// reset checkboxes function[/color]  
onReset = function () {  
var options;  
for (options in myCheck) {  
myCheck[options].setValue(false);  
}  
}

[color=red]// submit what the user has selected - it is here I want the evaluation bit to occur[/color]

onSubmit = function () {  
trace(myAnswer);  
}

It is when the user clicks on the submit button that I want to compare myAnswer to a correctAnswer variable and based a feedback path on whether they match or not (if…else…).

At the minute the myAnswer variable is returning the checkbox labels. I’d ideally like it to return the instance names/option numbers and make a comparison to the correct answer.

I’m sure I’m going about this completely the wrong way - hopefully someone can help 😉
