作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
如何获取这个多选下拉框的值?我不知道如何获得这些值。请帮忙解决这个问题。谢谢!
<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>
最佳答案
试试这个:
<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 = $('#test').val();
$('#getvalue').val(value);
}
</script>
关于javascript - 如何获取多选下拉框的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49568136/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!