object.options.remove(index)鏂規硶縐婚櫎options闆嗗悎涓殑鎸囧畾欏癸紱
object.options(index)鎴杘ptions.item(index)鍙互閫氳繃绱㈠紩鑾峰彇options闆嗗悎鐨勬寚瀹氶」錛?
select鏍囪榪樻湁涓涓睘鎬т負selectedIndex錛岄氳繃瀹冨彲鑳借幏鍙栧綋鍓嶉夋嫨鐨刼ption绱㈠紩錛歰bject.selectedIndex
1.娓呯┖options闆嗗悎
function optionsClear(object)
{
var length = object.options.length;
for(var i=length-1;i>=0;i--){
e.options.remove(i);
}
}
2.娣誨姞涓欏規柊option
function addOption(object)
{
object.add(new Option(label,value));
//浣跨敤options闆嗗悎涓渶鍚庝竴欏硅幏鍙栫劍鐐?/span>
object.selectedIndex = object.lentht-1;
}
3.鍒犻櫎options闆嗗悎涓寚瀹氱殑涓欏筼ption
function removeOption(index)
{
if(index >= 0)
{
object.remove(index);
//浣跨敤options闆嗗悎涓渶鍚庝竴欏硅幏鍙栫劍鐐?/span>
object.selectedIndex = object.lentht-1;
}
}
4.鑾峰彇褰撳墠閫夊畾鐨刼ption鐨勭湡瀹炲紇alue
function getCurrentOptionValue(index)
{
if(index >= 0)
return object(index).value;
}
5.鑾峰彇褰撳墠閫夊畾鐨刼ption鐨勬樉紺哄糽abel
function getCurrentOptionLabel(index)
{
if(index >= 0)
return object(index).text;
}

]]>