Hi All – this is more of a best practise question rather than a “How do I do…” – I have a form that submits to a function for evaluation to produce a result that shows or hides a div based on the result. The form is simply four drop downs.
Obviously I will use logical operators to make a decision, but is there a better way of writing the length number of combinations? ie
if (thisform.dropDown1.selectedIndex == 1 &&
thisform.dropDown2.selectedIndex == 1 &&
thisform.dropDown3.selectedIndex == 1 &&
thisform.dropDown4.selectedIndex == 1 &&
) {
//do whatever
}
it just seems I will have a stack of if statements in my .js file.
Just had a thought – would gathering the results first into variable – such as var count = thisform.dropDown1.selectedIndex;
var count += thisform.dropDown2.selectedIndex; etc
Then do a switch() on the count var? That might work; can anyone suggest a better way of doing this?
thanks
frank