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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:12:11+00:00 2026-05-23T19:12:11+00:00

having spent hours on this problem i need to throw it out to the

  • 0

having spent hours on this problem i need to throw it out to the masses. I have a test page at http://sketch360test.co.uk/test.php on which I’m trying to use onclick events to serve two purposes at once… 1) to show/hide various results div (this is working), and 2) to change the background image(s) of the ‘question’ divs. All of the ‘question’ divs have a green background image by default (controlled by CSS), a black image on rollover… and I’m trying to get them to each have a black image onclick, as well as resetting the bg image for all the OTHER question divs to green when one is clicked. Hope that makes sense… it should be more obvious if you view the page!

I’ve managed to get this working for a single instance, ie… clicking either Question 1, Question 2 or Question 3 will turn them to a black bg. This has been done using an inline onclick function to call a css class, for example:

<div id="section-menu-1" onclick="this.className='className2';">Question 1</div>

I have then added some more javascript to the container for this element (Question 1), which manages to ‘reset’ or ‘revert’ the black bg of Question 3 to green. This has been done using the following script:

<script type="text/javascript">

function changeClass()
{
 var e = document.getElementById("section-menu-3");
 e.setAttribute('class', 'className1');
 e.setAttribute('className', 'className1'); // for IE which does not recognize "class"
 return;
}
</script>

Please note here that I have tried NUMEROUS scripts for changing the class of my DIVs, this is the only one that works consistently. Herein lies the problem though – I want to modify the above script to affect all of the Question ID’s, not just “section-menu-3”. Incidentally, there are only 3 Questions in this demo but I will have up to 7 or 8 on the final page and so need to modify the above script to be able to take numerous ID’s. I’ve tried things like getElementsByTag but haven’t been able to get them to work (perhaps because I’m trying to add a class to an element that I’ve already applied one to for that process).

Anything else I’ve tried has ended up breaking the functionality of the above mini-script.

Basically, HELP! [ please :)) ]

  • 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-23T19:12:13+00:00Added an answer on May 23, 2026 at 7:12 pm

    Take a look at this demo: fiddle

    This should put you in the right direction.

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

Sidebar

Related Questions

I've been having problems with this code I had spent the last 3 hours
Spent some time troubleshooting a problem whereby a PHP/MySQL web application was having problems
I'm having a problem reading and processing data from my server. I've spent hours
I have spent hours on a debugging problem only to have a more experienced
I've spent many hours trying to figure how to do this: Having a placemark/annotation
I have spent hours trying to find an answer to this, and have come
I've spent about 6 hours on this so far, and been hitting nothing but
This may be a n00b topic but, anyways, I have been having a rather
I'm having this problem for a while now. I tried so many things that
I'm having this issue with a regular expression in PHP that I can't seem

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.