上传的同时删除select里当前选中的optionsselectname.remove(selectname.options[selectname.selectedIndex].index)

解决方案 »

  1.   

    function delSelectItem()
    {
    var eList=document.all.sltList;
    var eLength=eList.options.length

    for (var i=eLength-1;i>=0;i--) 
    {
    if(eList.options[i].selected )
    {
    eList.options[i]=null;
                                         retrun false;
    }
    }
    }
      

  2.   

    仅供参考
    function GetSelectValue(combox)
    {
    for(i=0;i<combox.length;i++)
    {
    if(combox.options[i].selected)
    {
    return combox.options[i].value;
    }
    }
    return null;
    }
    function AddNode()
    {
    var strPathName=window.location.pathname;
    var inParameter="NULL"+","+"NULL"+","+GetSelectValue(document.forms[0].ModelID);
    var outResult=showModalDialog(strPathName.substring(0,(strPathName.lastIndexOf('/')+1))+"Define_Node.jsp?Node=NULL&Action=NULL&ModelID="+GetSelectValue(document.forms[0].ModelID),inParameter,"dialogWidth:12;dialogHeight:6;dialogTop:400;dialogLeft:500;status:no;");
    if(outResult=="False")
    {
    }
    else
    {
    var outParameter=outResult.split(",");
    var strOutNode=outParameter[0];
    var strOutAction=outParameter[1];
    var strOutNode_,strOutAction_;
    strOutNode_=strOutNode.split("_");
    strOutAction_=strOutAction.split("_");
    document.forms[0].ListNode.length=document.forms[0].ListNode.length+1;
    document.forms[0].ListAction.length=document.forms[0].ListAction.length+1;
    var iLen=document.forms[0].ListNode.length;
    document.forms[0].ListNode.options[iLen-1].value=strOutNode_[0];
    document.forms[0].ListNode.options[iLen-1].text=strOutNode_[1];
    document.forms[0].ListAction.options[iLen-1].value=strOutAction_[0];
    document.forms[0].ListAction.options[iLen-1].text=strOutAction_[1];
    }
    }
    function DelNode()
    {
    var iIndex=GetSelectValue(document.forms[0].ListSerial);
    var iLen=document.forms[0].ListNode.length;
    if(iIndex==iLen)
    {
    document.forms[0].ListNode.length=document.forms[0].ListNode.length-1;
    document.forms[0].ListAction.length=document.forms[0].ListAction.length-1;
    }
    else
    {
    for(kIndex=iIndex;kIndex<iLen;kIndex++)
    {
    document.forms[0].ListNode.options[kIndex-1].value=document.forms[0].ListNode.options[kIndex].value;
    document.forms[0].ListNode.options[kIndex-1].text=document.forms[0].ListNode.options[kIndex].text;
    document.forms[0].ListAction.options[kIndex-1].value=document.forms[0].ListAction.options[kIndex].value;
    document.forms[0].ListAction.options[kIndex-1].text=document.forms[0].ListAction.options[kIndex].text;
    }
    document.forms[0].ListNode.length=document.forms[0].ListNode.length-1;
    document.forms[0].ListAction.length=document.forms[0].ListAction.length-1;
    }
    }
      

  3.   

    function s_add(){
      o_Option = new Option("name","value")  //向select中添加,这里的name和value自己传递值
      s1.add(o_Options,s1.options.length)
    }
    function s_del(){  //删除所选择的options,支持多选
      for(i=0;i<s1.options.length;i++){
        if(s1.options[i].selected==true){
      s1.remove(s1.options[i].index)
      i--
    }
      }
    }<SELECT NAME="s1" multiple>