Wednesday, 15 May 2013

javascript - Disable checkbox having different date -



javascript - Disable checkbox having different date -

<?php while($row = mysqli_fetch_array($result)){ ?> <tr> <td> <input type="checkbox" id="<?php echo $row['invoice_id']; ?>" name="invoice_id[]" rel="<?php echo $row['due_date']; ?>" value="<?php echo $row['invoice_id'];?>"> </td> <td><?php echo $row['invoice_no']; ?></td> <td><?php echo $row['due_date']; ?></td> </tr> <?php } ?>

my question how disable check box not equal due date of first check box checked

example

invoice_no due_date 1 10-15-2014 2 10-15-2014 3 10-16-2014 4 10-17-2014

if checked invoice_no 1, invoice_no 3 , 4 disabled , if unchecked invoice_no 1, check_box enabled

as of have , don't know whats next thing do, search web still cant find how this

$("input[type=checkbox]").change(function() { $due_date = $(this).attr("rel"); });

tia help.....

check out code..

class="snippet-code-js lang-js prettyprint-override">$(document).ready(function(){ $("input[type=checkbox]").change(function() { //alert($(this).attr("rel")); $due_date = $(this).attr("rel"); $id = $(this).val(); var $check = false; if($(this).is(':checked')){ $("input[type=checkbox]").each(function(){ if($(this).val()!=$id){ if($(this).attr("rel")==$due_date){ $(this).prop('disabled',false); }else{ $(this).prop('disabled',true); } } }); }else{ $("input[type=checkbox]").each(function(){ if($(this).val()!=$id & $(this).is(':checked')){ $check = true; } }); if(!$check){ $("input[type=checkbox]").each(function(){ $(this).prop('disabled',false); }); } } }); }); class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="checkbox" id="1" name="invoice_id[]" rel="10-15-2014" value="1"> <input type="checkbox" id="2" name="invoice_id[]" rel="10-15-2014" value="2"> <input type="checkbox" id="3" name="invoice_id[]" rel="10-16-2014" value="3"> <input type="checkbox" id="4" name="invoice_id[]" rel="10-17-2014" value="4">

this work.. :)

javascript php

No comments:

Post a Comment