您的位置:首页 > Web前端 > JavaScript

js里对options的增加删除提交操作

2006-08-07 15:32 351 查看
function AddRight()
{
var index=document.form1.selectNewsone.selectedIndex;
var obj2=document.form1.selectk
if (index<0) return false;
var value=document.form1.selectNewsone.options[index].value;
var text=document.form1.selectNewsone.options[index].text;
if(fexist(obj2,value)==false)
{
obj2.options.add(new Option(text,value,true,true));
}
}

function fexist(object,value){
for(var i=0;i<object.options.length; i++)
{
if(object.options[i].value==value)
return true;
}
return false;
}
function RemoveItem(obj1)
{
var index=obj1.selectedIndex;
if(index<0)return false;
obj1.options.remove(index);
}
function postForm()
{
var KindObject=document.form1.selectKind
var KindText=document.form1.KindArray
var i
i=0
for(i;i<KindObject.options.length; i++)
{
if(i==0)
{
KindText.value=KindText.value.concat(KindObject.options[i].value)
}
else
{
KindText.value=KindText.value.concat(",")
KindText.value=KindText.value.concat(KindObject.options[i].value)
}
}
document.form1.submit()
}
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: