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 8543233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:15:13+00:00 2026-06-11T12:15:13+00:00

Like the title says, I have a problem with checkbox validation. So, I have

  • 0

Like the title says, I have a problem with checkbox validation.
So, I have this line in my php file which displays users.

<a href='#' onclick='if(confirm("Are you sure?"))checkbox.submit()' class='bt_red'><span class='bt_red_lft'></span><strong>Delete items</strong><span class='bt_red_r'></span></a>

in my delete_items.php file I wrote the following :

$checkbox = $_REQUEST['checkbox'];
if(!isset($checkbox)) {
//diplay an error message :"No user selected"
} else {
if(isset($checkbox)) {
// deleting users script
}
}

In the 2 cases, when clicking on the “delete items” , I get the javascript confirmation message, which I don’t want to display when no checkbox is set (the if(!isset($checkbox)) statement).

thank you for help.

  • 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-11T12:15:14+00:00Added an answer on June 11, 2026 at 12:15 pm

    You would want to make the javascript code inside your links onclick statement aware of how many checkboxes have been clicked. This is rather easy. If you use Jquery you can just query them like this:

    $("input[type=checkbox]:checked").size();
    

    This just evaluates to how many checkboxes are checked anywhere on your page, so you would have to narrow down the query with a parent element or class or something.

    When you have the number of checked checkboxes, its just a matter of some AND and OR like this:

    $("input[type=checkbox]:checked").size() > 0 && (confirm("do you really want to do this?"));
    

    The first expression evaluates to true if there are checked checkboxes, so the second expression gets evaluated, otherwise not.

    hope this helps

    edit: you could also use if instead of or. maybe that’s a little bit more familiar

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

Sidebar

Related Questions

As the title says I have a string like this: $string = "Hello World<br>hello
As title says, I have a list of words, Like stopWords = [the, and,
Like the title says, PHP is really confusing me on a simple if comparison
Like the title says, I have the following exception: Description: Event code: 3005 Event
Like the title says, I want to have a HTML table that allows its
Like the title says, i have a parent window with button that opens a
as the title says, I would like to have a black font with a
As the title says... I have a route (the first one listed) which looks
Just like the title says I am having problems combining two classes. Altough this
Like the title says, I'm looking for an HMAC-SHA1 implementation for C#. This will

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.