<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script> $(document).ready(function () { $('#d').click(function() { if (this.checked==true) { $('input[name="vehicle[]"]').prop('checked', true); } if (this.checked==false) { $('input[name="vehicle[]"]').prop('checked', false); } }); }); </script> <form action="" method="post"> <input type="checkbox" name="df" value="Bike" id="d">click to select all<br> <input type="checkbox" name="vehicle[]" value="scooter">scooter<br> <input type="checkbox" name="vehicle[]" value="suzuki">suzuki<br> <input type="checkbox" name="vehicle[]" value="yamaha">yamaha<br> <input type="checkbox" name="vehicle[]" value="honda">honda<br> <input type="checkbox" name="vehicle[]" value="Car">car <input type="submit" value="submit" name="sub"/> </form> <?php if(isset($_POST['sub'])) { $a=$_POST['vehicle']; print_r($a); } ?>
No comments:
Post a Comment