2个listbox用JS实现左右倒,明明有数据,为什么我在后台me.listbox2.items.count 为0呢?
我想取的listbox2中所有选项的value值,该怎么做?

解决方案 »

  1.   

    页面上放个隐藏字段hdnPotList
    再提交数据判断函数里面加上
    var potlists = '';
    for(ix=0; ix<frmProg.listbox2.length; ix++)
    {
    potlists += frmProg.listbox2.options[ix].value + ",";
    }
    frmProg.hdnPotList.value = potlists.substring(0, potlists.length-1);
    //这里frmProg只所在的form名称
    后台获取hdnPotList.Value 就可以了
      

  2.   

    js作的数据在后台是取不到的 
    把你的listbox2中被选中的数据存放到一个隐藏的text中,在后台取隐藏的text中的值就可以了
      

  3.   

    to 1楼的大哥
        这些代码在加到哪呢?提交数据判断函数是指哪个?function Test( lbFieldsSelect,value)
    {
    for (j = 0;j<lbFieldsSelect.length; j++)
    {                    
    if (lbFieldsSelect.options[j].value == value) return true;            
    }
    return false;
    }

    function SelectField()
    {                        
    var lst1=window.document.getElementById("lstBoxLeft");
    var lstindex=lst1.selectedIndex;
    if(lstindex<0)
    return;
    var v = lst1.options[lstindex].value;
    var t = lst1.options[lstindex].text;
    var lst2=window.document.getElementById("lstBoxRight");
    if (Test(lst2,v))
    {
    return;
    }
    lst2.options[lst2.options.length] = new Option(t,v,true,true);
    lst1.options[lstindex].parentNode.removeChild(lst1.options[lstindex]);

    }