Solved

Confirm javascript

Posted on 2013-01-28
2
271 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now