Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8989589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:17:53+00:00 2026-06-15T22:17:53+00:00

After click the button Delete, How to display an alert if none of checkbox

  • 0

After click the button “Delete”, How to display an alert if none of checkbox is selected.
My html form

<form name="Delete" method="post" action="DeleteAdministrator">
                <table width="800px" cellpadding="5" style="color:black; border-top:1px solid #ccc;" border="0">
                </table>
                    <div id="container">
                    <div id="demo_jui">
                    <table id="adminList" class="display" cellpadding="0" cellspacing="0" border="0" style="font-size:12px;" >
                    <thead id="headed">
                    <tr>
                        <th  align="center" title="Select">Select</th>
                        <th align="center" title="Email Address">Email Address</th> 
                        </tr>
                    </thead>
                    <tbody></tbody>
                    </table>
                    </div>
                    </div>
                    <table id="footed">
                        <tr>
                            <td colspan="2">
                                <a href="#"><img src="images/Delete.png" style="border:none;" onClick="javascript:Go()"
                                onmouseover="this.src='images/Delete_Hover.png'" onmouseout="this.src='images/Delete.png'"/></a>
                                &nbsp;&nbsp;&nbsp;
                                <a href="#"><img src="images/Reset.png" style="border:none;" onClick="javascript:clearForm()"
                                onmouseover="this.src='images/Reset_Hover.png'" onmouseout="this.src='images/Reset.png'"/></a>
                            </td>
                        </tr>
                    </table>
                </form>
</body>
</html>

The checkbox value will be retrieved in table. When I test it,
When checkbox is select or non-select, it still alert “Please select to delete admin”

In function Go(), is the way validate document.Delete.delAdlist[i].checked correct? Thank you

<script language="JavaScript">                      
    var running = 0;
    function Go() {
        var f = document.forms[0];
        for (i = 0; i < document.Delete.delAdlist.length) {
            if (!document.Delete.delAdlist[i].checked) {
                alert("Please select to delete admin.");
                return false;
            }
            else {
                f.submit();
                return true;
            }
        }  
        f.submit();
        running++;
    }                               
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:17:55+00:00Added an answer on June 15, 2026 at 10:17 pm

    It would be more logical to look for checked items, and when the first one is found: submit the form and quit. If none are found checked then the alert is shown. You haven’t shown the checkbox HTML so I’m assuming you have a checkbox array named delAdlist[].

    Plain Javascript Solution

    function Go() {
        var f = document.forms["Delete"];
    
        for (i = 0; i < f.elements["delAdlist[]"].length; i++) {
           if (f.elements["delAdlist[]"][i].checked) {
                f.submit();
                return true;
            }
        }  
    
        alert("Please select at least one to delete");
    }
    

    jQuery Solution

    function Go() {
        if($('form[name=Delete] input[name=delAdlist\\[\\]]:checked').length > 0)
        {
            $('form[name=Delete]').submit();
        }
        else
        {
            alert("Please select at least one to delete");
        }
    }
    

    Note: the above code will work if your checkboxes are an array. If your checkboxes are not an array and are all named delAdlist (without brackets) then remove [] from the first solution, and change the selector in the second solution to form[name=Delete] input[name=delAdlist]:checked

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On the page 'selecteditems.php' I have a form like this: <form method=POST name=selecteditems action=nextpage.php>
I want make a alert that after click on button delete ask did you
when I click submit button it shows the validation right but after that alert
What the program should do: After the user clicks the delete button with a
I am updating multiple records and after I click submit button I get the
I want to change data on listview runtime after button click... here is my
I want create an application with animate button? how can i do? after click
I want to make a button that starts my php script after I click
I am facing a problem while disabling the command button after one click. I
I need a field to store some information after one asp button click for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.