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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:09:01+00:00 2026-06-13T11:09:01+00:00

I have a php script that outputs images, at the moment to select an

  • 0

I have a php script that outputs images, at the moment to select an image you have to click a checkbox. I want to change this so that when the parent div is clicked the checkbox is set to checked.

I know how to do this if i have a different id for the parent div, and the class seems to be no good as it would set all of the checkboxs the php has outputted as true/false.

this is what i have so far:

JQuery

$('#div').bind('click', function() {
   var checkbox = $(this).find(':checkbox');

    checkbox.attr('checked', !checkbox.attr('checked'));
});

HTML (Outputted by php, so multiples exist.)

<div id="div" style='display:inline-block; padding:15px;' class='lifted drop-shadow-sq'>
    <img class='reflect reflect-br'  width='150px' height='150px' src=\"thumb.php?id=$id\">
        <input type='checkbox' class=\"show-man\" name=\"images[]\" value='$id'>
</div>

So how would i set the checkbox as checked when the parent div is clicked in a way that wouldn’t cause conflict between any other checkbox?

thanks for any help in advance.

  • 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-13T11:09:02+00:00Added an answer on June 13, 2026 at 11:09 am

    Your selector is wrong there is no element with ID of div in your markup, you can use prop method:

    $('div').on('click', function() {
       $('input[type=checkbox]', this).prop('checked', function(i, checked){
          return !checked
       })
    });
    

    Please note that :checkbox selector is deprecated and IDs must be unique, if you have multiple elements with the same IDs your markup is invalid and your ID selector only selects the first element with that specific ID, you should use classes instead.

    $('.div').on('click', function() {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php script that outputs a random image each time it's called.
I have a php/imagick script that outputs a png image but when I go
I have php script that creates a temporary watermark image for users that are
So I have this php script that output an html table with data about
I have a php script that outputs json data. For the purposes of testing,
I have a PHP script that has as input a target image and an
I have a php script that I use to send images to mobile devices
I have a simple PHP script that outputs a dir listing in XML format.
So I have a PHP script file that resizes images on the fly. While
I have a PHP script that outputs valid XML to the browser. Is there

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.