multiselect dropdown with checkboxes functionality - php

Folks
We are creating the application and used the jquery as discussed in this website
we are using multiple select dropdown with checkboxes. ( as in the screenshot attached)
The issue is
we cannot update the return result of the ajax call.
eg
if i select the date to and date from then the result between these two dates should be filtered and should be displayed in the multiple select dropdown with checkboxes.
Let me know if there is any other way to implement the same.( multi select dropdown along with the checkbox functionality).

You want to use `$("select").multiselect('refresh');`
//create new object with ajax data
var opt = $('<option />', {
value: "new value",
text: "new text"
});
opt.appendTo(jqselect );
jqselect.multiselect('refresh');

I use the chosen (from jquery-chosen).
In chosen you can specify a filter, where you can use select with multi or not.

Related

Second select load from database after first one is selected

I have 2 select items.
In the first one I'm loading the options from a MySQL database table using PHP.
The second one I want to load the fields from another table where for example category field equals the value of the item selected on the first tag.
I have no idea about how I can make the second select tag load the options dynamically. I know I need to use Ajax I guess.
I've found this, but it doesn't help too much since the options of the first select tag depend on what it can find in the database.
// Given the options in the first dropdown are: "foo", "bar", and "baz"
var secondData = {
foo: ['lorem', 'ipsum'],
bar: [1,2,3],
baz: []
}
Then I need to add a 'change' event to the first dropdown, and given the value of that dropdown, load the contents of the second dropdown with the values contained in the secondData object, but I can't apply this.
If you want to get the values for the second dropdown from a database, then you do need ajax.
See this post:
Populate dropdown 2 based on selection in dropdown 1
A couple of other good posts re the basics of AJAX:
A simple example
More complicated example

Getting the values from the multiselect Group in jquery plugin

I am working on multiselect group. Here is the link i have populated some data in the multiselect group and the users can select their requirements in that.
http://vignesh.gvignesh.org/chose/chose.php
Here once show selected button is clicked i am calling javascript function.
function chos()
{
var a = $(".chzn-select").chosen();
alert(a);
}
it is not showing the selected values in alert box. Some [object][object] is displayed.
i dont know how to get the selected values. If my javascript function for getting the values is wrong kindly let me know the new function.
Thanks in Advance.
Just use $("#chossen").val(), which returns an array of values that are currently selected.
To get the actual option elements that are selected, try $("#chossen").find("option:selected");, and then loop through those (obviously) - in case you want to get their text.

how can i populate the value of dropdownbox while selecting the value of another website in php

I have two dropdown box one for country and second for states
what i should do ? I would select the country from the first dropdown box and
second dropdown box should be filled up with name of the states of concerned country
i want to use jquery and PHP
states and countries are stored in mysql database
How to do dynamic dependent select box using Jquery, Ajax, PHP and Mysql. Dependent select box when a selection is made in a "Parent" box it allow to refresh a "child" box list data.
http://www.9lessons.info/2010/08/dynamic-dependent-select-box-using.html
The below code will be triggered when the selected value of your country drop down list changes.
You could then use a PHP script to return a JSON list of states which will then be populated into your states drop down list.
$('#IdOfYourCountryList').change(function(){
var country = $(this);
$.getJSON("UrlOfYourPHPScript", function(result) {
$.each(result, function() {
options.append($("<option />").val(this.Value).text(this.Key));
});
});
});
this.Key and this.Value refer to the name and value you want for each option, the names may change based on how you structure the JSON.
Tones of examples of this kind of thing. Google is your friend. Here's one example:
http://roshanbh.com.np/2008/01/populate-triple-drop-down-list-change-options-value-from-database-using-ajax-and-php.html

Dropdown not updating when selected via Ajax

I have two select dropdowns, regions and towns. If the region is selected, it updates the towns dropdown with the appropriate towns for that region using Ajax.
I am trying to use an imagemap to select the dropdown for region, which should update the towns, but it is not. The value for region dropdown gets selected but the ajax does not fire to update towns. All works fine if not using the imagemap. Is the image map select jQuery below not actually updating the select box the way I think it is? Any ideas?
//ImageMap Selectors
$('area', '#regionmap').click(function(){
$("#region").val($(this).attr('alt'));
});
The onchange event is not fired when an option is selected programmatically. Trigger the event manually by tacking on a call to .change().
$("#region").val($(this).attr('alt')).change();

how to get the dropdown value?

Hi i am using dropdown for display the timezone.The timezone values are come from database.Whenever the user change the value I need to alert the new timezone.For example if user change the time GMT+5.30 to GMT+6.30 then I want to alert GMT+6.30.Here the the dropdown values coming as an array?What can I do to get the values?
If you're using select and you have set values for your options, you can:
$("select#dropdown").change(function(){
alert($(this).val());
});
To do this, you need the jQuery framework. http://www.jquery.com/
checkout http://www.texotela.co.uk/code/jquery/select/ plugin for handling select element, very handy.

Categories