jsSelectItemByValue();
动态删除select中的某一项option:
var sObj=document.getElementById("ddlResourceType");
sObj.removeChild(sObj.options[indx]);
动态添加select中的项option:
document.getElementById("ddlResourceType").options.add(new Option(text,value));
动态删除select中的某一项option:
var sObj=document.getElementById("ddlResourceType");
sObj.removeChild(sObj.options[indx]);
动态添加select中的项option:
document.getElementById("ddlResourceType").options.add(new Option(text,value));
//更新form中的填充
function getDepartName(nodeid){
var url="${ctx}/duty/base/identitydep!getIdentitydeptNameByAjax.action?d="+Math.random();
$.getJSON(url,{nodeid:nodeid},function(json){
//如果有id重复的,就让其选中
$(json).each(
function(i){
document.getElementById("parent_update").options.add(new Option(json[i].name,json[i].id));
}
);
//去掉最后一个option
var sObj=document.getElementById("parent_update");
sObj.removeChild(sObj.options[getJsonLength(json)-1]);
//选中要选的id
jsSelectItemByValue($("#parent_update")[0], json[getJsonLength(json)-1].id);
});
}
function getJsonLength(json){
var len=0;
if(Boolean(json)){
for(i in json)len++;
}
return len;
}