我的多选列表是这样的:<select id="selmember" name="right_select" size="15" style="width:100px" multiple>
    </select>
现在我想把从另一个多选列表传到这个列表的值赋给一个隐藏的域<input name="ddd" type="hidden" />,多个值之间用“,”分开,怎么办啊,帮帮我

解决方案 »

  1.   

    <html>
    <head>
    <SCRIPT language="javascript">
    function testGG(){
          var selTest = document.getElementById("selmember");
      var optTest = selTest.getElementsByTagName("option");
      var temp = "";
      for(var i = 0; i<optTest.length;i++){
          if(optTest[i].selected){
          temp = temp+optTest[i].value+",";
      }
      }
      
      document.getElementById("textGG").value = temp;
    }
    </SCRIPT>
    </head>
    <body>
    <select id="selmember" name="right_select" size="15" style="width:100px" multiple>
    <option value="a">a</option>
    <option value="b">b</option>
    <option value="c">c</option>
    <option value="d">d</option>
    </select>
    <input type="text" width="200" id="textGG"/>
    <input type="button" value="ok" onClick="testGG()"/>
    </body>
    </html>
      

  2.   

    妥了,L@_@K<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> select move and save multiple options </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="[email protected]" />
      <meta name="keywords" content="javascript" />
      <meta name="description" content="for javascript region of csdn" />
     </head> <body>
    <select id="selmember" name="left_select" size="15" style="width:100px" multiple>
    </select>
    <input type="button" id="btnSelect" value=">>" />
    <select id="selmember" name="right_select" size="15" style="width:100px" multiple>
    </select>
    <input type="hidden" id="hidResult" />
    <input type="button" id="btnShow" value="show result" /><script type="text/javascript">
    <!--
    var oLeft = document.getElementById("left_select");
    var oRight = document.getElementById("right_select");
    var oSelect = document.getElementById("btnSelect");
    var oResult = document.getElementById("hidResult");
    var oShow = document.getElementById("btnShow");for (var i=1; i<16; i++)
    {
        oLeft.options.add(new Option(i, i));
    }
    oSelect.onclick = function() {
        for (var i=0; i<oLeft.options.length; i++)
        {
            if (oLeft.options[i].selected)
            {
                oRight.appendChild(oLeft.options[i].cloneNode(true));
                oResult.value += oLeft.options[i].value + ",";
            }
        }
        if (oResult.value.length>0)
        {
            oResult.value = oResult.value.slice(0, oResult.value.length-1);
        }
    };oShow.onclick = function() {
        alert(oResult.value);
    };//-->
    </script>
     </body>
    </html>