?
Solved

Confirm javascript

Posted on 2013-01-28
2
Medium Priority
?
277 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 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