js裏對options的增加刪除提交操作


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> 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章