Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using datalist.... Inside datalist i am using html checkboxs... I want to check whether the particular checkbox is checked or not in serial order. consider the first checkbox irrespective of first checkbox checked or not... If i am choosing second and fourth checkbox leaving third checkbox den it should display alert message that choose in serial order.. so struck in javascript function how to display error message
Posted

1 solution

Use the following code for your reference, it will help you solve your problem.

C#
function SelectAll(id) {
            //get reference of GridView control
            var grid = document.getElementById("<%= this.myGridView.ClientID %>");
            //variable to contain the cell of the grid
            var cell;

            if (grid.rows.length > 0) {
                //loop starts from 1. rows[0] points to the header.
                for (i = 1; i < grid.rows.length; i++) {
                    //get the reference of first column
                    cell = grid.rows[i].cells[0];

                    //loop according to the number of childNodes in the cell
                    for (j = 0; j < cell.childNodes.length; j++) {
                        //if childNode type is CheckBox
                        if (cell.childNodes[j].type == "checkbox") {
                            //assign the status of the Select All checkbox to the cell checkbox within the grid
                            //                            cell.childNodes[j].checked = document.getElementById(id).checked;
                            if (!cell.childNodes[j].checked) {
                                alert("Please check in serial order");
                            }
                        }
                    }
                }
            }
        }



Thanks and Regards
Amit Dutta
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900