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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:06:08+00:00 2026-05-26T01:06:08+00:00

I have a dynamically produced photo gallery using ASP. Each photo is contained by

  • 0

I have a dynamically produced photo gallery using ASP. Each photo is contained by a <div> with the photoID as the ID and a checkbox to select that photo. For example:

<div id="<%=rs("photoID")%>">
<img src="blah.jpg"><br>
<input type="checkbox" id="checkbox_<%=rs("photoID")%>" onclick="selectPhoto(<%=rs("photoID")%>)">
</div>

I will then have a JS function that changes that particular DIVs background color to show it is selected, I just made this up, hope it’s right:

function selectPhoto(id)
{
if (document.getElementById('checkbox_'+id).checked == true)
{
document.getElementById(id).style.backgroundColor = '#0066CC';
}
if (document.getElementById('checkbox_'+id).checked == false)
{
document.getElementById(id).style.backgroundColor = '#FFFFFF';
}
}

So, if the checkbox that was clicked, was checked, then change BG color to something that highlights my photo. If the checkbox that was clicked, was not checked, then change back to the original color.

This seems simple enough to achieve but where I’m now getting confused, is how I could change all the highlighted photos back to white, in one go, if a user clicks an ‘un-select’ checkbox called ‘unselect_all’.

I’m thinking of a function that will gather all checked checkboxes in that form ‘gallery_form’, get the ID’s of the checkboxes, minus the ‘checkbox_’ prefix, then change all those DIV ID’s back to the original color, white.

Or… I could alter the DIVs to have an ID prefix, like ‘photo_<%=rs(“photoID”)%>’, find all DIV Id’s that have that prefix, then change the background colors.

Is this the best way to accomplish this? If it is, has anybody got any suggestions/snippets to get me going? Although I can see the function in my head, my basic JS skills don’t allow me to write such a script, without a little help..

Many thanks

  • 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-05-26T01:06:09+00:00Added an answer on May 26, 2026 at 1:06 am

    I would suggest using classes to make your life easier. So each of the colors would be a css class i.e

    .blue{
       background-color: #0066CC; 
    }
    
    .white{
       background-color: #FFFFFF; 
    }
    
    function selectPhoto(id){
       var checkbox = $('#checkbox_'+id); 
       var div = $('#'+id);        
    
       if( checkbox.is(':checked') )
           div.addClass('blue'); 
       else 
           div.addClass('white'); 
    }
    

    Then for unselect all

    function unselectAll(){
       $('.blue').removeClass('blue').addClass('white'); // find all divs with class blue and add class white. 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many checkboxes in a dynamically produced (ASP) photo gallery. Each checkbox has
I have a function that dynamically creates links for a photo gallery. The function
I have a gallery of products that is dynamically created using php and mysql
I have the array example below that I am using to dynamically create an
I have a checkbox list control on my asp.net web form that I am
I have a table produced dynamically with each row producing something like this: <tr
I have an href in HTML that I dynamically produce from a server. I
I have a dynamically created image that I am saving to a stream so
I have a dynamically generated rss feed that is about 150M in size (don't
I have a script on my server that dynamically creates images of chess diagrams:

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.