zoukankan      html  css  js  c++  java
  • 输出选中的下拉框的值

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
            <select id="objsel" name="objsel" size=8 multiple>
                <option value="0" selected>请选择
                <option value="1">测试一
                <option value="2">测试二
                <option value="3">测试三
                <option value="4">测试四
                <option value="5">测试五
            </select>
            <input type="button" onclick="checkselect();" value="输出">
            选中的项目:<input type="text" id="output" name="output">
    </body>
    </html>
    <script language="JavaScript">
        function checkselect(){
            var x = document.getElementById("objsel");
            var t = document.getElementById("output");
            var count=0;
            var intvalue="";
            for(i=0;i<x.length;i++){
                if(x.options[i].selected){
                    intvalue+=x.options[i].value+",";
                    count++;
                }
            }
            t.value=intvalue.substr(0,intvalue.length-1);
    //        alert(count);
        }
    </script>

    效果图:

  • 相关阅读:
    SQL注入的一般步骤及防范方法
    防止SQL注入的五种方法
    document.getElementById("orderform").submit() 提交给了谁?
    页面调试-F12
    rs.last()续
    rs.last()
    14课后习题
    HashMap
    链表
    习题
  • 原文地址:https://www.cnblogs.com/heyiming/p/6600329.html
Copyright © 2011-2022 走看看