jCombo
This plugin simplifies the process to populate data into SELECT tags, even if nested or not. The only condition is to put the fields in query consecutively in order to create pairs of [value],[text] inside the Json File. Unobtrusive, without fancy effects, just takes data as fast as possible.
Project page: http://www.prodiven.com/jcombo
Documentation
Case 1 (getCountries.php outputs a json array with key=>values):
$("select[name='country']").jCombo("getCountries.php");
Dependent select:
$('#state').jCombo("getStates.php?id=", {
parent: "#country", // parent for nested combos
initial_text: "-- Plese Select --", // Initial option
selected_value: "5" // default selected value
});
Options
parent: Parent SELECT element from which data is fetched
initial_text: Default message to select an option. if you set an empty value then does not shows any initial text.
selected_value: Sets the default value for select.
method: [ "GET" (default), "POST" ]
dataType: [ "json" , "jsonp" ] is an $.ajax dataType (jsonp as default)