Select a radio / checkbox in JS

  • Views Views: 11,217
  • Last updated Last updated:
  • // 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');
    }
Back
Top