hummm,

not that simple. It's multiple radios with multiple values
so how to get id and value of selected one?




lionel28 wrote:
> 
> Thanks for replying.
> I am going to try your code.
> 
> 
> Shawn Grover wrote:
>> 
>> 
>> 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.
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Ajax-populating-select-box-based-on-radio-selected-tp25869309s27240p25870135.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to