I’ve made a test of the “Most A answers? Then you’re type A” kind. Depending on the visitor’s answers I want my script to open one of three pages in a new window.
The problem is that it only opens one page (page c) no matter what I answer, and when my colleague tries it she only gets page a. I’ve tried clearing the cache and form memory as well as trying it in different browsers but it doesn’t help, and each radio button has the correct value (a, b or c). What am I doing wrong?
Thankful for advice!
/Cajsa
[code=php]<script language=”JavaScript” type=”text/javascript”>
<!– Begin
var done = new Array;
var ascore = 0;
var bscore = 0;
var cscore = 0;
function Engine(question, answer) {
if (!done[question]) {
done[question] = -1;
if (answer == “a”) ascore=ascore+1;
if (answer == “b”) bscore=bscore+1;
if (answer == “c”) cscore=cscore+1;
}
else {
alert(“Du har redan svarat!”);
}
}
function NextLevel () {
if (ascore >= bscore && ascore >= cscore){
window.open(“http://www.rfsu.se/test_sexuell_identitet_a.asp”,”mywindow”);
}
if (bscore >= ascore && bscore >= cscore){
window.open(“http://www.rfsu.se/test_sexuell_identitet_b.asp”,”mywindow”);
}
if (cscore >= ascore && cscore >= bscore){
window.open(“http://www.rfsu.se/test_sexuell_identitet_c.asp”,”mywindow”);
}
}
</script>
P.S. I call the script with this line of code:
[code=php]<INPUT TYPE=”button” VALUE=”Se resultat” onclick=”NextLevel ()”>