1. NOTICE: If you are using Fabrik and update to Joomla 3.10, you will need to update to Fabrik 3.10. And, if you are using Fabrik, do not upgrade to Joomla 4, we do not have a supported version ready for release. More information on a release date coming soon. Also, please note that Fabrik 3.10 will not install on any Joomla sites less than 3.8.
    Dismiss Notice

Select a radio / checkbox in JS

Aug 5, 2013
Select a radio / checkbox in JS
  • Code (Javascript):
    // get the div that contains the checkboxes
    // this div is the element which uses the elemnent's full name as its id.
    var div = $('tablename___elementname');
     
    //get its checkboxes
    var inputs = div.getElements('input[type=checkbox]');
     
    //or to get radiobuttons
    var inputs = div.getElements('input[type=radio]');
     
    //access a specific input and see if its checked or not
     
    if(inputs[0].checked){
        alert('the first input is checked')
    } else {
        alert('the first input in not checked');
    }