jazzyjade
11-26-2003, 08:04 AM
Is there a way to combine these first three else conditions into an else statement like the one at the bottom? I want to condense the code but can't figure how to get it to work. Thanks!
else if (a[1]==1&&b[1]==1){
else if (a[2]==1&&b[2]==1){
else if (a[3]==1&&b[3]==1){
else if ((a[1]==1&&b[1]==1)||(a[2]==1&&b[2]==1)||(a[3]==1&&a[3]==1)) {
Gollum
11-26-2003, 08:09 AM
The condition in the last if statement looks fine. What problem are you running into?
jazzyjade
11-26-2003, 08:19 AM
I don't know what's wrong. If I leave the code as it was originally (using the first 3 else statements), the script works fine. But when I use the bottom statement, the script stops working. When writing the last script, I guessed at the syntax since I couldn't find any documentation on how to combine multiple condidtions, so I figured I was doing it incorrectly. But you're saying the code is correct?
Here's my actual code. Maybe you could let me know if you see anything wrong in there.
function checkanswer(){
//makes sure an answer is selected
if (setLayer[0]==0&&setLayer[1]==0&&setLayer[2]==0&&setLayer[3]==0&&setLayer[4]==0&&setLayer[5]==0&&setLayer[6]==0){
alert('You must make a selection before clicking the Submit button.');}
// the rest of the script checks to see if the selected answer was already chosen
else if ((alreadySelected[1]==1&&setLayer[1]==1)||(alreadySelected[2]==1&&setLayer[2]==1)||(alreadySelected[3]==1&&setLayer[3]==1)||(alreadySelected[4]==1&&setLayer[4]==1)||alreadySelected[5]==1&&setLayer[5]==1)||(alreadySelected[6]==1&&setLayer[6]==1)){
alert('You already selected that option. Please make a new selection.');
MM_showHideLayers('perform','','show','perform2','','hide','contact','','show','contact2','','hide', 'ask','','show','ask2','','hide','provide','','show','provide2','','hide','unable','','show','unable 2','','hide');
setLayer[1]=0;setLayer[2]=0;setLayer[3]=0;setLayer[4]=0;setLayer[5]=0;setLayer[6]=0;
} else {
submitClicked = submitClicked+1;
feedback();
return false;
}
}
Gollum
11-26-2003, 08:30 AM
yup, you're missing a ( before the bit that says alreadySelected[5]==1&&setLayer[5]==1)
jazzyjade
11-26-2003, 08:34 AM
Now I'm blushing. Don't know why I ever try to get stuff done before a holiday! My brain never works right...
Thanks for your help!