Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何获取多选下拉框的值_Javascript_Jquery - Fatal编程技术网

Javascript 如何获取多选下拉框的值

Javascript 如何获取多选下拉框的值,javascript,jquery,Javascript,Jquery,如何获取此多选下拉框的值?我不知道怎样才能得到这些值。请帮忙。谢谢 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.jquery.min.js"></script> &

如何获取此多选下拉框的值?我不知道怎样才能得到这些值。请帮忙。谢谢

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.jquery.min.js"></script>
    <link href="https://cdn.rawgit.com/harvesthq/chosen/gh-pages/chosen.min.css" rel="stylesheet"/>
  </head>
  <body>
      <select data-placeholder="Begin typing a name to filter..." multiple class="chosen-select" name="test" id="test">
        <option value=""></option>
        <option>American Black Bear</option>
        <option>Asiatic Black Bear</option>
        <option>Brown Bear</option>
        <option>Giant Panda</option>
        <option>Sloth Bear</option>
        <option>Sun Bear</option>
        <option>Polar Bear</option>
        <option>Spectacled Bear</option>
      </select>
      <input type="text" name="getvalue" id="getvalue">
      <input type="button" onclick="a()" value="Submit">
    <script>
    $(".chosen-select").chosen({
      no_results_text: "Oops, nothing found!"
    });

    function a() {
      var value = document.getElementById('test').value;
      document.getElementById('getvalue').value = value;
    }
    </script>
试试这个:

美国黑熊 亚洲黑熊 棕熊 大熊猫 懒熊 太阳熊 北极熊 眼镜熊 $.select-select.select{ 没有结果文本:哎呀,什么也没有找到! }; 功能a{ var值=$'test'.val; $'getvalue'.ValveValue; }
您无法在下拉列表中分配onchange事件。为了获得更好的结果,请使用JQuery的.val:

$.select-select.select{ 没有结果文本:哎呀,什么也没有找到! }; 功能a{ var值=$'test'.val; document.getElementById'getvalue'。value=value; } 美国黑熊 亚洲黑熊 棕熊 大熊猫 懒熊 太阳熊 北极熊 眼镜熊 $.select-select.select{ 没有结果文本:哎呀,什么也没有找到! }; $button.clickfunction{ a=$.select-select.val; console.loga; } 美国黑熊 亚洲黑熊 棕熊 大熊猫 懒熊 太阳熊 北极熊 眼镜熊 点击我
在HTML中尝试此函数:

功能a{ var selectSelected=document.getElementByIdgetvalue; var collection=document.getElementByIdtest.selectedOptions;
对于var i=0;i对于下拉选项,您可能需要如下内容:

"
var conceptName=$'test'.find:selected.text;'

是否尝试了$'test.val?它将返回一个包含所有选定值的数组显示我可以使用它从数据库中筛选记录?是否可行?如何使用它从数据库中筛选记录?是否可行?如何使用它从数据库中筛选记录?是否可行?