🤯 50% Off! 700+ courses, assessments, and books

jQuery XML Combo Box

Sam Deering

This is an easy way to use jquery and xml to populate a combo box (drop down) which could be used for populating dynamic options to the combo box based upon an xml configuration data file (which contains the options). This method could be useful for forms that have constantly changing options.

Here is how you do it.


jQuery Code

				type: "GET",
				url: "dropdown.xml",
				dataType: "xml",
				success: function(xml) {
					var select = $('#mySelect');
						var title = $(this).find('title').text();
							var value = $(this).text();
					select.children(":first").text("please make a selection").attr("selected",true);

XML Code

    	first set
 			option a
 			option b
    	second set
 			option 1
 			option 2
    	third set
 			option 1a
 			option 2b

Download Source Files