如何判断一个字符,在一个数组里?
我目前的写法:
----------------------------------------
function changeselect1(locationid)
{
if(locationid==3||locationid==4)
{
document.MyForm.A10.options[1].selected=true;
}
else if(locationid==1||locationid==2||locationid==5||locationid==6||locationid==8||locationid==9)
{
document.MyForm.A10.options[2].selected=true;
}
else
{
document.MyForm.A10.options[0].selected=true;
}
}
-----------------------------------------
现在都是用||作条件判断的~~~
现在想先定义1个数组,如下:
var subcat = new Array();
subcat[0] = new Array('3','4')
subcat[1] = new Array('1','2','5','6','8','9')
目的:
if(locationid在subcat[0]) {....}
else if (locationid在subcat[1]){...}
else {.....}