Author Topic: Set pqSelect from ajax  (Read 4127 times)

[email protected]

  • Newbie
  • *
  • Posts: 1
    • View Profile
Set pqSelect from ajax
« on: August 24, 2015, 07:19:48 pm »
I used to bind the pqSelect throug ajax(json). I want to set the pqselect with some value that fetch from the database in xml format and check box to be checked for that particular items.. Please help me to sort out the problem

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>ParamQuery Select</title>
    <!--jquery dependencies-->
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/redmond/jquery-ui.css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="https://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
    <!--pqSelect dependencies-->
    <link rel="stylesheet" href="pqselect.dev.css" />
    <script src="pqselect.dev.js"></script>
    <script type="text/javascript" language="javascript">
        var html = "";
        var select = [];
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "WebService.asmx/BindMultiSelectDropdown",
                data: "{}",
                dataType: "json",
                success: onSuccess,
                error: function (result) {
                    alert("Error");
                }
            });

        });
        function onSuccess(data) {
         //Data bind process successfully over here
            });
            $('#select3').html(html);
            $("#select3").pqSelect({
                multiplePlaceholder: 'Select Regions',
                checkbox: true
            })
        }
       
        $(function () {
            $("#select3").on("change", function (evt) {
                var val = $(this).val();
                //alert(val);
                select.push(val);
            }).pqSelect('open');
        });
        function saveValue(opt) {
          Data Sava

        }
    </script>
    <script type="text/javascript">
       
    </script>
   
   
   
</head>
<body>
    <div>
        <select id='select3' multiple="multiple" style="margin: 20px; width: 300px;">
        </select>
        <br />
        <input type="button" id="btnsave" value="Save" onclick="saveValue(1)" />
    </div>
</body>