Select Radio button based on dropdownbox selection

TjerkH 03 Nov, 2015
Answer
Hi,

For a Scoutsgroup I'm creating a form and I want to select the gender based on the group selected in the dropdown box.

With help of Bob we cam to this code

jQuery(document).ready(function(jQ){
  jQ('#teamchoice').on('change', function(){
    var event;
    event = jQ('#teamchoice').val();
    if ( event == 'girlsteam') {
      jQ('#radio11').attr('checked', true);
      jQ('#fin-radio11 input:radio').attr('disabled', true);
    } else {
       jQ('#radio11').attr('checked', false);
      jQ('#fin-radio11 input:radio').attr('disabled', false);     
    }
  });
});


So far so good, but if I want to output the form (on screen or email) it does not give me the selection of radiobutton. Its simply stating {radio11}. Whereas when I select the radiobutton manualy it works perfectly fine.

Any help in this possibly silly question would be appreciated. Just starting to learn playing around with simple coding.
GreyHead 04 Nov, 2015
1 Likes
Hi Tjerk,

My mistake - please replace 'disabled' with 'readonly' in both places. When an element is disabled it doesn't return anything.

Bob
TjerkH 04 Nov, 2015
Thank you Bob! Works perfect.
This topic is locked and no more replies can be posted.