动态创建select
function createSelect(){
var mySelect = documentcreateElement_x("select");
mySelectid = "mySelect";
documentbodyappendChild(mySelect);
}
添加选项option
function addOption(){
//根据id查找对象
var obj=documentgetElementByIdx_x(mySelect);
//添加一个选项
objadd(newOption("文本""值"));
}
删除所有选项option
function removeAll(){
var obj=documentgetElementByIdx_x(mySelect);
objoptionslength=;
}
删除一个选项option
function removeOne(){
var obj=documentgetElementByIdx_x(mySelect);
//index要删除选项的序号这里取当前选中选项的序号
var index=objselectedIndex;
objoptionsremove(index);
}
获得选项option的值
var obj=documentgetElementByIdx_x(mySelect);
var index=objselectedIndex; //序号取当前选中选项的序号
var val = objoptions[index]value;
获得选项option的文本
var obj=documentgetElementByIdx_x(mySelect);
var index=objselectedIndex; //序号取当前选中选项的序号
var val = objoptions[index]text;
修改选项option
var obj=documentgetElementByIdx_x(mySelect);
var index=objselectedIndex; //序号取当前选中选项的序号
var val = objoptions[index]=new Option("新文本""新值");
删除select
function removeSelect(){
var mySelect = documentgetElementByIdx_x("mySelect");
mySelectparentNoderemoveChild(mySelect);
}