Solved

Confirm javascript

Posted on 2013-01-28
2
274 Views
Last Modified: 2013-01-29
i want a confirm javascript. i dont want the pop up to show up on a button click or any other event. instead i want it show up  when i do the following

"i have a datagrid with check boxes and when multiples rows are selected i want a confirm pop up ."
0
Comment
Question by:pratikshahse
2 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 250 total points
ID: 38829281
Here's sample code to start:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script  type="text/javascript">
        $(function () {
           $("#btnSave").click(function () {
                var checkedboxes =$("#dataTable  input:checkbox:checked").length;
                if (checkedboxes > 1)
                    return confirm("Do you want to Save " + checkedboxes + " records");
                else
                    return true;
            });
        });
</script>

<table id="dataTable">
            <tr>
                <td>
                    <asp:CheckBox ID="chb1" runat="server" Text="One" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="CheckBox1" runat="server" Text="Two" />
                </td>
            </tr>
        </table>
        <asp:Button ID="btnSave" runat="server" Text="Button" />

Open in new window

0
 
LVL 10

Assisted Solution

by:Monica P
Monica P earned 250 total points
ID: 38830619
USe "onchange" event of checkbox u have in your design

http://stackoverflow.com/questions/2697329/get-number-of-checkboxes-that-are-checked-in-javascript


   <input type="checkbox" onclick="OnChangeCheckbox (this)" id="myCheckbox" />

Open in new window

 <script type="text/javascript">
        function OnChangeCheckbox (checkbox) {
            if (checkbox.checked) {
                alert ("The check box is checked.");
            }
            else {
                alert ("The check box is not checked.");
            }
        }
    </script>

Open in new window



check number of checkbox count using

var cnt = $('.chkBoxList input:checked').length;

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question