天天看點

JS 擷取select (多選下拉)中所選中的值

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

JS 擷取select (多選下拉)中所選中的值

<html>

JS 擷取select (多選下拉)中所選中的值

 <head>

JS 擷取select (多選下拉)中所選中的值

  <title> New Document </title>

JS 擷取select (多選下拉)中所選中的值

  <meta name="Generator" content="EditPlus">

JS 擷取select (多選下拉)中所選中的值

  <meta name="Author" content="">

JS 擷取select (多選下拉)中所選中的值

  <meta name="Keywords" content="">

JS 擷取select (多選下拉)中所選中的值

  <meta name="Description" content="">

JS 擷取select (多選下拉)中所選中的值

 </head>

JS 擷取select (多選下拉)中所選中的值
JS 擷取select (多選下拉)中所選中的值

 <body>

JS 擷取select (多選下拉)中所選中的值
JS 擷取select (多選下拉)中所選中的值

<script language="JavaScript">

JS 擷取select (多選下拉)中所選中的值

  <!--

JS 擷取select (多選下拉)中所選中的值

function checkselect(objname){

JS 擷取select (多選下拉)中所選中的值

    o = document.getElementById(objname);

JS 擷取select (多選下拉)中所選中的值

    t = document.getElementById("output");

JS 擷取select (多選下拉)中所選中的值

    var intvalue="";

JS 擷取select (多選下拉)中所選中的值

    for(i=0;i<o.length;i++){   

JS 擷取select (多選下拉)中所選中的值

        if(o.options[i].selected){

JS 擷取select (多選下拉)中所選中的值

            intvalue+=o.options[i].value+",";

JS 擷取select (多選下拉)中所選中的值

        }

JS 擷取select (多選下拉)中所選中的值

    }

JS 擷取select (多選下拉)中所選中的值

    t.value=intvalue.substr(0,intvalue.length-1);

JS 擷取select (多選下拉)中所選中的值

}

JS 擷取select (多選下拉)中所選中的值

  //-->

JS 擷取select (多選下拉)中所選中的值

  </script>

JS 擷取select (多選下拉)中所選中的值

  <select name="objsel" size=8 multiple>

JS 擷取select (多選下拉)中所選中的值

    <option value="0" selected>請選擇

JS 擷取select (多選下拉)中所選中的值
JS 擷取select (多選下拉)中所選中的值

    <option value="1">測試一

JS 擷取select (多選下拉)中所選中的值

    <option value="2">測試二

JS 擷取select (多選下拉)中所選中的值

    <option value="3">測試三

JS 擷取select (多選下拉)中所選中的值

    <option value="4">測試四

JS 擷取select (多選下拉)中所選中的值

    <option value="5">測試五

JS 擷取select (多選下拉)中所選中的值

  </select>

JS 擷取select (多選下拉)中所選中的值

<input type="button" οnclick="checkselect('objsel');" value="輸出">

JS 擷取select (多選下拉)中所選中的值

選中的項目:<input type="text" name="output">

JS 擷取select (多選下拉)中所選中的值

 </body>

JS 擷取select (多選下拉)中所選中的值

</html>

版權聲明:本文為CSDN部落客「weixin_34051201」的原創文章,遵循CC 4.0 BY-SA版權協定,轉載請附上原文出處連結及本聲明。

原文連結:https://blog.csdn.net/weixin_34051201/article/details/92023791