Click here to Skip to main content
15,918,976 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Dear Experts,

i have used a template to develop an Asp.net application. And i have used Ajax JSON in my project.

And now i am stuck in populating the dropdownlist(HTML SELECT Control).

I am Used ajax JSON to populate the Datas in dropdownlist contains theme...




JavaScript
$.ajax(
                {
                    type: "POST",
                    url: "../../WebService.asmx/populate_Division",
                    dataType: "json",
                    data: JSON.stringify({ "Standard_ID": document.getElementById('ddl_Standard').value }),
                    contentType: "application/json; charset=utf-8",
                    success: function (json) {

                        var xmlDoc = "";
                        var xml = "";
                        xmlDoc = $.parseXML(json.d);
                        xml = $(xmlDoc);

                        document.getElementById("ddl_Division").innerHTML = "";
                       

                        $(xml).find("Table1").each(function () {
                            var Division_ID = $(this).find("Division_ID").text();
                            var Division = $(this).find("Division").text();
                          

                           $("#ddl_Division").append("<option value='" + Division_ID + "'>" + Division + "</option>");
                            
                          
                          
                        });
                       
                    }
                });







when i used the theme in dropdownlist then the datas are not populated. But when i remove the theme of that dropdownlist then the datas are populated properly.....

jquery.chosen.js


I need to populate with this theme...

HERE IS THE LINK TO DOWNLOAD THE SAMPLE PROJECT Download NOW


OR

PLease see the jsFiddle Preview

jsFiddle Priview





NOTE: This sample project is in HTML Pages... please check the data.js file




Thanks and Regards,

Dileep
PLease Help me to Solve this problem....
Posted
Updated 6-Apr-13 2:17am
v7
Comments
vinodkumarnie 6-Apr-13 5:25am    
file not available..
dilzz 6-Apr-13 5:26am    
wait a bit SIR,.. am updating that file.........
dilzz 6-Apr-13 6:17am    
Sir,.... I Have uploaded the file.. please download it....

Thanks.......

1 solution

change code from
JavaScript
$("#ddl_State").append("<option value='" + i + "'>" + State_Name + "</option>");

to this
JavaScript
$(".chzn-results").append("<li id=\"ddl_State_chzn" + i + "\" class=\"active-result\" style=\"\"> " + State_Name + " </li>");

See the js fiddle[link].This is a basic step.You will do more work with them..
 
Share this answer
 
v7
Comments
dilzz 6-Apr-13 10:44am    
Thank u Sir, For ur great reply.. ur code is perfectly working..... now the datas are populating fine.... but i can't select any items...... what is the reason for that...

Thank you,

Dileep
Manu Thalasseril 6-Apr-13 10:56am    
You are using a plugin for getting the theme for dropdown list. That drop down list will be replaced or code added by plugin. So all controls goes to that plugin.Also you will write
your own logic to that plugin for your customization or go through the documentation of that plugin or study the plugin by yourself.You can integrate your code in that plugin and use it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900