in short, no. Not that I know of. I mean no plugin per se. The
code/script is simple enough though...
$("#myradio").click( function () {
$.ajax({
url: "somepage.php",
data: "id=somevalue",
dataType: "json",
success: function (results) {
var opts = "";
for (x=0; x < results.length; x++) {
opts += "<option>" + results[x] + "</option>";
}
$("#mySelect").empty().append(opts);
}
});
});
that's kinda rough, but should get the point across. The results you
get back from the ajax call can be whatever you want - a new HTML
definition of the select element, a json array of objects, a simple
array of text values (as hinted at in the sample code), or even xml.
Whatever you pick for the results format dictates what you have to do
with the results to get it into your select list.
The flexibility and diversity of the approaches here are probably why
there is no (known) plugin. Yet the code is simple enough to slap
together in less than 5 minutes.
HTH.
Shawn
lionel28 wrote:
Hello,
Is there a script that allows to get values to populate a select box via
ajax when a radio button is clicked?
Thank you.