0
<?php
$con = mysql_connect("localhost","root","");
$db = mysql_select_db("abc");
if(!$db){
echo 'Could Not connect database';
}
$sel = mysql_query("select * from user_registration");
?>


<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('input[type="checkbox"]').click(function(){

            //how to select multiple checkbox value here??????????


        });
    });
</script>

    <div>
    <?php
    while($row = mysql_fetch_array($sel)){
    ?>
        <label>
        <input type="checkbox" name="<?php echo $row['user_id']; ?>" value="<?php echo $row['user_id']; ?>">
        <?php echo $row['first_name']; ?>
        </label>
     <?php
    }
     ?>
    </div>
   <div class="display"></div>
2
Contributors
1
Reply
16
Views
3 Years
Discussion Span
Last Post by Ajay Gokhale
0

Hi,

Please find following Javascript functions to select / deselect checkbox using div (This will apply checkboxes in a div)

<script type="text/javascript">
function checkedall(divname) {
    $("#" + divname).find(':checkbox').each(function () {
        $(this).attr('checked', true);
    });
}

function uncheckedall(divname) {
    $("#" + divname).find(':checkbox').each(function () {
        $(this).attr('checked', false);
    });
}
</script>

You can all above functions like

<a href="javascript:void(0);" onclick="javascript:checkedall('div_nave');">Select All</a>

In short you can use following code for single checkbox using Id
$('#checkbox_id').attr('checked', true);

If you have any query, Please let me know.
Thanks,
Ajay

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.