I have a checkbox, populates the combox on both checked and unchecked. I am using AJAX to populates. When checkbox is checked, It works fine, but when I unchecked It wont work, actually it wont do anything.

<input type="checkbox" name="course_inactive" id="course_inactive" onclick="courseStatus(document.getElementById('batch').value, document.getElementById('batch').value)">

If remove courseStatus() function is removed, it shows both values.

Member Avatar for Member #120589

I'd use jquery for this, and get rid of the inline js. Either stuff it in the head with $('document').ready or at the end of the page.

$('#course_inactive').click(function()){

  if($('#course_inactive').attr('checked')){
    /* call ajax function to populate dropdown */
  }else{
    /* use default content or whatever */
  }

)};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.