本文介绍了使用selected-select jquery保存多个下拉列表选择值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的js& css文件。

Here is my js & css File.

<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js" type="text/javascript"></script>
    <script src="chosen.proto.js" type="text/javascript"></script>
    <script src="docsupport/prism.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        document.observe('dom:loaded', function (evt) {
            var config = {
                '.chosen-select': {},
                '.chosen-select-deselect': { allow_single_deselect: true },
                '.chosen-select-no-single': { disable_search_threshold: 10 },
                '.chosen-select-no-results': { no_results_text: "Oops, nothing found!" },
                '.chosen-select-width': { width: "95%" }
            }
            var results = [];
            for (var selector in config) {
                var elements = $$(selector);
                for (var i = 0; i < elements.length; i++) {
                    results.push(new Chosen(elements[i], config[selector]));
                }
            }
            return results;
            
        });
  </script>





这是我的设计div



Here is my design div

<div class="side-by-side clearfix">
    <div>
        Single Select with Groups
    </div>
    <div>
        <asp:DropDownList ID="ddlchk1" runat="server" data-placeholder="Your Favorite Football Team" style="width: 350px;" multiple class="chosen-select">
    </div>
</div>



此代码工作正常并显示多个选定的下拉值,但我想将选定的值保存到我的sql server数据库。



我的尝试:



这是我的js文件代码。我想填充选定的值,但它不能正常工作。


This code working perfectly and display multiple selected dropdown value, but I want save the selected valu to my sql server database.

What I have tried:

Here is my js file code. I want populate the selected values but its not working perfectly.

$(document).ready(function () {
    alert("dsd");
    $(document).ready(function () {
        $("#ddlchk1").chosen();
        $("#btnSubmit").click(function () {
            console.log($("#ddlchk1").val());
            alert(console.log($("#ddlchk1").val()));
        });
    });
})

推荐答案





这是我的设计div



Here is my design div

<div class="side-by-side clearfix">
    <div>
        Single Select with Groups
    </div>
    <div>
        <asp:DropDownList ID="ddlchk1" runat="server" data-placeholder="Your Favorite Football Team" style="width: 350px;" multiple class="chosen-select">
    </div>
</div>



此代码工作正常并显示多个选定的下拉值,但我想将选定的值保存到我的sql server数据库。



我的尝试:



这是我的js文件代码。我想填充选定的值,但它不能正常工作。


This code working perfectly and display multiple selected dropdown value, but I want save the selected valu to my sql server database.

What I have tried:

Here is my js file code. I want populate the selected values but its not working perfectly.




这篇关于使用selected-select jquery保存多个下拉列表选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 22:17