1
以下代碼在選擇框中操作選項時正常工作。但是當我把它放在表格中時它不起作用。請幫忙。提前致謝。訪問表單元素時的問題
<html>
<head>
<title>Catogery list</title>
<script type="text/javascript">
var catogeries=new Object();
catogeries['Accessories'] = 'Cosmetics/Perfumes|Jewelry|Handbags|Shoes|Watches';
catogeries['Entertainment/Media'] = 'Videos/Movies|Art|Photo|News|Television|Music';
catogeries['Automobile'] = 'Cars| Motorcycles| Tools & Supplies| Accessories';
catogeries['Books & Magazines'] = 'eBooks| Audio Books| Books| Magazines';
catogeries['Business & Career'] = 'Real Estate| Office| Productivity Tools| Employment| B-TO-B| Marketing';
catogeries['Apparel'] = 'Childrens| Mens| Womens';
function subcat(elem)
{
var catarr;
var subb=document.getElementById("subcat");
subb.disabled=false;
subb.length=0;
var cat=elem.options[elem.selectedIndex].text;
if(catogeries[cat])
{
catarr=catogeries[cat].split('|');
subb.options[0]=new Option('select subcat',' ');
for(var i=0; i<catarr.length; i++)
{
subb.options[i+1]=new Option(catarr[i],catarr[i]);
}
}
}
</script>
</head>
<body>
<select id="cat" onChange="subcat(this,subcat)" style="width:200px;">
<option value="" selected="selected">Select Catogery</option>
<option value="">Accessories</option>
<option value="">Entertainment/Media</option>
<option value="">Automobile</option>
<option value="">Books & Magazines</option>
<option value="">Business & Career</option>
<option value="">Apparel</option>
</select>
</br>
</br>
<select id="subcat" style="width:200px; " disabled="true">
</select>
</body>
</html>