Hulk
Hulk

Reputation: 34180

checkbox attributes in jquery

In IE7 only onselecting selectall checkbox only one checjbox gets selected on firefox this works fine..How can this be fixed

   <input type='checkbox' id='selectall' name='selectall' class='selectall' onclick='javascript:selectall1();' /><label><b>Select all</b></label><br>
      <input type="checkbox" id="m_q" name="m_q" value="485">
       select country
      <input type="checkbox" id="m_q" name="m_q" value="486">Select state

<script>
function selectall1()
{
 if ($('#selectall').attr('checked')) {
    $("#m_q:not([disabled='disabled'])").attr('checked', true);
  }
 else{
  $("#m_q:not([disabled='disabled'])").attr('checked', false);
 }

}
 </script>

Upvotes: 0

Views: 246

Answers (2)

Marc B
Marc B

Reputation: 360742

You've used the same 'id' for two of the checkboxes. This is wrong. IDs are supposed to be unique on any given page, so there's no reason to expect multiple elements with the same ID to be processed.

Upvotes: 0

dionyziz
dionyziz

Reputation: 2462

You should not be using the same id on two different elements.

Upvotes: 2

Related Questions