I have a while loop where I get data from database:
<div class="full_qst">
<div class="drvr"> <?php echo $driver; ?> </div><span class="divider">|</span>
<div class="sbd_drvr"> <?php echo $subdriver; ?> </div><span class="divider">|</span>
<div class="qst"> <?php echo $skill; ?> </div>
<div class="mrk">
<label class="choice" for="q1_a" >
<input id="q" name="q1_a[]" type="checkbox" value="<?php echo $low ?>" />
1</label>
<label class="choice" for="q1_a" >
<input id="q" name="q1_a[]" type="checkbox" value="<?php echo $middle ?>" />
2</label>
<label class="choice" for="q1_a" >
<input id="q" name="q1_a[]" type="checkbox" value="<?php echo $good ?>" />
3</label>
<label class="choice" for="q1_a" >
<input id="q" name="q1_a[]" type="checkbox" value="<?php echo $vrgood ?>" />
4</label>
</div>
</div>
I get around 15 records. What I want is to allow user check checkbox for each line separately and allow them check only on box on same line. So instead of this:
I tried to implement this:
$('.mrk input#q').on('change', function() {
if($(this).is(':checked')){
$(':checkbox[name="' + $(this).prop('name') + '"]').not($(this)).prop('checked',false);
}
});
But it deselects previous box on upper line and allow me to choose only one checkbox in whole page. Is there a way to solve it?
Aucun commentaire:
Enregistrer un commentaire