Comments (14)
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.
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.
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.
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.
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.
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.
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.
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.
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.
Could you please guide me how to read the item values and it's item index value as well?
from multiple-select.
Sorry.. reading the selected values.
from multiple-select.
Please checkout examples and documentation at http://wenzhixin.net.cn/p/multiple-select/#setselects-getselects
from multiple-select.
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.
You can try:
$("#cblselect").html(html.join('')).multipleSelect({
filter: true
}).multipleSelect("uncheckAll");
from multiple-select.
Related Issues (20)
- can you create a composer install support?
- Disable event checkAll and uncheckAll while using filter.
- when filter character ک arabic in search box no result found HOT 3
- Inch Problems
- Align records to the right? HOT 1
- The Vue notation doesn't work HOT 2
- Can't set placeholder for Single select HOT 3
- Proposal: Navigation with Arrow Keys and List Close on Enter/Tab in Multiple-Select Component HOT 2
- onFilter event retrieves text only lowercase format HOT 1
- Not getting selected data in Laravel Livewire
- getSelects() undefined is not iterable HOT 2
- 关于filter搜索中文问题(IOS设备) HOT 1
- Enable/disable options ? HOT 2
- Uncaught TypeError: Cannot read properties of undefined (reading 'locales')
- Select all doesn't work with filtered result (with optgroup)
- Array’s mutation methods can not trigger the vue component view updates
- Multiple MultipleSelect components are bound to a same variable using v-model, but only the first one works.
- Data attributes don't work
- Vue3 component error
- A form field element should have an id or name attribute ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multiple-select.