<script language="javascript">
var 请选择=new Array("请选择");
var dogs=new Array("poodle","puli","greyhound");
var birds=new Array("robin","hummingbird","crow");
var fish=new Array("trout","mackerel","bass");
var array_length=arrayLength;
//按照名字把相关项目变成数组
function swapOptions(the_array_name){
var numbers_select=window.document.the_form.the_examples;
var the_array=eval(the_array_name);
setOptionText(numbers_select,the_array);
}
//给选定的数组项赋值
function setOptionText(the_select,the_array){
for(loop=0;loop<the_array.length;loop++)
{
the_select.options[loop].text=the_array[loop];
}
}
//取得选定数组的长度
function arrayLength(array){
array_length=array.length;
return array_length;
}
document.write(array_length)
</script>
</head>
<body>
<form name="the_form">
<select name="choose_category"
onChange="swapOptions(window.document.the_form.choose_category.options[selectedIndex].text);">
<option selected>请选择</option>
<option>dogs</option>
<option>fish</option>
<option>birds</option>
</select>
<select name="the_examples">
<option selected>请选择</option>
<script language="javascript">
for(i=0;i<array_length;i++)
document.write("<option>")
</script>
</select>
</form>
我想让他按照数组的长度来确定有多少个<option>怎么弄啊,弄了一个下午了,本来想找个全局变量的,可是不懂怎么在函数里面把值传给全局变量,求救,求救哦````