I need help ( checking function)

What doesn’t work?

scotty(-:

Try:

function validate(n) {
	for (var i = 1; i<=5; i++) {
		if (this["Scene12input"+i] == answers[n][0]) {
			for (var i = 1; i<=5; i++) {
				if (this["Scene12input"+i] == answers[n][1]) {
					for (var i = 1; i<=5; i++) {
						if (this["Scene12input"+i] == answers[n][2] || answers[n][2] == undefined) {
							return true;
						}
					}
				}
			}
		}
	}
}

OMG, that was a bad bad code :stuck_out_tongue:

LOL, i never even specify the answers that are correct???

answers = [["+Tcos45", “-Rcos60”, “+Ltan30”], [“apple”, “orange”, “citron”]];
function validate(n) {
for (var i = 1; i<=5; i++) {
if (this[“Scene12input”+i] == answers[n][0]) {
for (var i = 1; i<=5; i++) {
if (this[“Scene12input”+i] == answers[n][1]) {
for (var i = 1; i<=5; i++) {
if (this[“Scene12input”+i] == answers[n][2] || answers[n][2] == undefined) {
return true;
}
}
}
}
}
}
}

LIKE THIS???

Place the following code on a frame:

answers = [["+Tcos45", "-Rcos60"], ["apple", "orange"],["car","bus","plane"]];//add the other pairs here
function validate(n) {
        for (var i = 1; i<=5; i++) {
                if (this["Scene12input"+i] == answers[n][0]) {
                        for (var i = 1; i<=5; i++) {
                                if (this["Scene12input"+i] == answers[n][1]) {
                                        for (var i = 1; i<=5; i++) {
                                                if (this["Scene12input"+i] == answers[n][2] || answers[n][2] == undefined) {
                                                        return true;
                                                }
                                        }
                                }
                        }
                }
        }
}

And this one on the button:

on (release) {
	for (var i = 0; i<answers.length; i++) {
		if (validate(i)) {
			trace("success");
			gotoAndStop("Scene 12", 2);
			break;
		}
	}
}

hey claudio, thats the same old problem…
i enter one correct ans “bus” , it also goes to next scene…

Ps: the answers now are all three answers in one set, thanks…

I didnt understand whats the problem. :q:

there are three answers u need to answer correctly…
“bus”, “plane”, “car”

The problem in the code is that when i input only one answer “bus” and press submit, it goes to the next scene…(-:

Weird i just tested here and it seems to work.

it works?? hmm…:h:

i just input the word “car” and presses submit, it show the debug window “success” which means its goes to next frame…

Check my attachment, i think its working.

now thats kinda weird…
does the input box need to have the same variable name as urs fla… i dont think so…

Yes, it has to be Scene12input1, Scene12input2,…, Scene12input5
I thought you had that on your file so i didnt even mention.

*Originally posted by MaTilDA *
**…basically there are 5 input boxes: scene12input1 - scene12input5… **

oh gosh:upset:
but previous i have named it input 1-5 now now i have to proceed on which i have labelled 6 - 10…

Hey i GOT IT!!! :smiley: :smiley: :smiley:
u guys out there earn my respect, u help me greatly, thanks to claudio and scotty…