Giter Club home page Giter Club logo

Comments (14)

wenzhixin avatar wenzhixin commented on September 25, 2024

What you say the way of adding dynamic values into the select control is like this example?
http://wenzhixin.net.cn/p/multiple-select/#the-refresh

from multiple-select.

nr2203 avatar nr2203 commented on September 25, 2024

Hi,
I have gone through this example.
I want to bind the option values dynamically on page load which will be coming from a web serice.
my query now.. how will i add those values to multiselect html control.

Thanks,
NR

from multiple-select.

nr2203 avatar nr2203 commented on September 25, 2024

Example:
abc 789

in the above code the option values '1' and 'abc' will come from web wervice so on page load how will i add to multiselect control.

hope, you understood.

Thanks,
NR

from multiple-select.

wenzhixin avatar wenzhixin commented on September 25, 2024

You can try:

<select id="select"></select>
<script>
$(function() {
  $.get('/service', function(options) { // get data from web service
    var html = [];
    $.each(options, function(i, option) {
      html.push('<option value="' + option.value + '">' + option.name + '</option>');
    });
    $('#select').html(html.join('')).multipleSelect(); // add options to select
  });
});
</script>

from multiple-select.

nr2203 avatar nr2203 commented on September 25, 2024

Hi,

Very thanks for your mail.

Please can you share me a simple script for adding dynamically into the control.

I may not call directly from script, we just load into server controls then will be updating the select control.

Thanks,

NR

From: 文翼 [mailto:[email protected]]
Sent: Wednesday, September 04, 2013 5:24 PM
To: wenzhixin/multiple-select
Cc: nr2203
Subject: Re: [multiple-select] how to add new options on page load (#16)

You can try:

<script> $(function() { $.get('/service', function(options) { // get data from web service var html = []; $.each(options, function(i, option) { html.push('' + option.name + ''); }); $('#select').html(html.join('')).multipleSelect(); // add options to select }); }); </script>


Reply to this email directly or view it on GitHub #16 (comment) . https://github.com/notifications/beacon/hDDtGalo9HeBo4STvqi6-3VKDIro17L17F0DfIN_HAh_y-vCyAU4cQ15ZFauhtaa.gif

from multiple-select.

wenzhixin avatar wenzhixin commented on September 25, 2024

Sorry, I do not know how you use it in your application, can you give me more information?
Or you can try these examples: http://wenzhixin.net.cn/p/multiple-select/#examples

from multiple-select.

nr2203 avatar nr2203 commented on September 25, 2024

Hi,

   <asp:CheckBoxList ID="cblChoices" runat="server">
            </asp:CheckBoxList>

At the movement the data is uploading into the above checkboxlist server control on page load . so now i want to use your multiselect control as replacement.

i just tried to update the

        <select id="cblselect" multiple="multiple" style="width: 230px; height: 50px">         
        </select>

 <script src="Scripts/jquery.multiple.select.js" type="text/javascript"></script>
        <script type="text/javascript">

                $("#cblselect").multipleSelect({
                    filter: true,

                });



            function loadselect() {
                var CHK = document.getElementById("<%=cblChoices.ClientID%>");
                var checkbox = CHK.getElementsByTagName("input");
                var label = CHK.getElementsByTagName("label");


                var select = document.getElementById("cblselect");

                for (i = 0; i < checkbox.length; i++) {
                    select.add(new Option(label[i].innerHTML, i));
                }
            }          

        </script>

just trying to call whole activity on <body loadselect()>

Finally i am looking to feed the options data using script on page load().

Hope you understood.

Thanks,
NR

from multiple-select.

wenzhixin avatar wenzhixin commented on September 25, 2024

You have to add jquery libary, and you can use to load the page like:

$(function() {

});

Hope to help:

<select id="cblselect" multiple="multiple" style="width: 230px; height: 50px">         
</select>

<script src="Scripts/jquery.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.multiple.select.js" type="text/javascript"></script>
<script type="text/javascript">                
        $(function() {

                var CHK = document.getElementById("<%=cblChoices.ClientID%>");
                var checkbox = CHK.getElementsByTagName("input");
                var label = CHK.getElementsByTagName("label");


                var html = [];

                for (i = 0; i < checkbox.length; i++) {
                    html.push('<option value="' + i + '">' + label[i].innerHTML + '</option>';
                }

                $("#cblselect").html(html.join('')).multipleSelect({
                    filter: true
                });
        });
</script>

from multiple-select.

nr2203 avatar nr2203 commented on September 25, 2024

Hi Wang,

It's perfectly working now, but it just selecting the first item in the list. why?

Any suggestions. please.

Thanks,

from multiple-select.

nr2203 avatar nr2203 commented on September 25, 2024

Could you please guide me how to read the item values and it's item index value as well?

from multiple-select.

nr2203 avatar nr2203 commented on September 25, 2024

Sorry.. reading the selected values.

from multiple-select.

wenzhixin avatar wenzhixin commented on September 25, 2024

Please checkout examples and documentation at http://wenzhixin.net.cn/p/multiple-select/#setselects-getselects

from multiple-select.

nr2203 avatar nr2203 commented on September 25, 2024

Hi Wang,

i have successfully implemented, but only one item left.

How to stop not select any item by default, since it is automatically selecting first item as selected.

Cheers,
NR

from multiple-select.

wenzhixin avatar wenzhixin commented on September 25, 2024

You can try:

$("#cblselect").html(html.join('')).multipleSelect({
    filter: true
}).multipleSelect("uncheckAll");

from multiple-select.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.