[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Confirm javascript

Posted on 2013-01-28
2
Medium Priority
?
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 1000 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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