<select...mutiple="true">
<html:option collection="bean" ...>问,如何取得多选框内所选择的序号??

解决方案 »

  1.   

    用jquery的插件
    有个插件像chinahr那样搜索功能的多选
    那么html的多选没用过
    有那种把左边的选到右边的没用过
      

  2.   

    js控制,取options[i].selected=true得值。
    下面函数取得所有已选得值,并用,分开返回。如果要text,就把.value改成.text。
    我都这么做,不知道有没有更简单得方法。function getSelectedValue(selectList){
    var value="";
       for (var i=0; i < selectList.length; i++){
         if( selectList.options[i].selected){
         value += selectList.options[i].value+",";
         }
    }
    return value;
    }
      

  3.   

    这个是把from选择的移动到to的: 即->
    function moveSelect(from,to){
    var s;
    for  (var i=0; i <=from.length - 1; i++){
    s = from.options[i];
    if(s.selected){
    to.add(document.createElement("OPTION"));
    to.options[to.length-1].text = s.text;
    to.options[to.length-1].value = s.value;
    }
    }
    for  (var i=from.length - 1; i >-1; i--){
    s = from.options[i];
    if(s.selected){
    from.options.remove(i);
    }
    }
    return true;
    }这个是把所有from的移到to的,即=>function moveAll(from,to){
    var s;
       for (var i=0; i <=from.length - 1; i++){
        s = from.options[i];
    to.add(document.createElement("OPTION"));
    to.options[to.length-1].text = s.text;
    to.options[to.length-1].value = s.value;
    }
    for  (var i=from.length - 1; i >-1; i--){
    from.options.remove(i);
    }
    return true;
    }
      

  4.   

    有没有什么属性值能够获得index,js试过,但是不太想用
      

  5.   

    这个是左边一个table表,右边是一个多选框,table表中每一行开头是一个checkbox,有两个按钮“添加”和“删除”,点添加,把左侧table表中check的数据放到多选框中,点“删除”,要把多选框中选中的数据从多选框中删除。有没有这样的例子啊,,,,,
      

  6.   

    select  中有个属性能够控制多选的
    你查查文档  我以前用过 
      

  7.   

    参考下这个
    http://penghuaiyi.javaeye.com/blog/391713