for getting selected check-box values i m using a j query which is run fine under chrome , Firefox but fails in IE. For certain reasons i gave same id for each check-box but use different names. for example
<input id="LIV" name="<?php echo $value['desc']; ?>" type="checkbox" checked value="<?php echo $value['id']; ?>" /> <?php echo $value['desc']; ?>
<a class="i-btn-2" onclick="addparameters('LIV');">Add</a>
On click of add button i call a function addparameter which is as follows
function addparameters(id)
{
var tempstr='#'+id+':checked';
$(tempstr).each(function(i)
{
val[i] = $('#'+id).val();
val1[i]=($(this).attr('name'));
str12=str12+val[i];
});
}
In IE if i selected more than one check-boxes it gives me only first check-box value.But in chrome it gives me all selected check-boxes values
What is wrong with my code. Please help me to run it on IE
As Neal said – each checkbox must have different ID – even every element in Your HTML has to have different ID – ID is what it is supposed to be – an IDENTIFICATOR and the IDETIFICATOR uniquely describes one concrete item.
Instead of ID You can use class or the same input name:
or