Check out my attempt at solving this challenge on jsfiddle: http://jsfiddle.net/oca3L32h/
In the scenario, there are 3 divs within a main div. Each of these divs contains an image and they overlap each other. By using radio buttons, the visibility of these divs can be controlled (showing one while hiding the others).
The goal is to create a Javascript function that will perform an AJAX query to the database when the page loads. If the response from the database is "0", a specific image should appear with 50% opacity overlaying the 3 divs. This semi-transparent image should prevent interaction with the original images underneath even when the radio buttons are clicked.
To simulate the database check in the jsfiddle, I added a "Click me" button that triggers the Javascript function. However, achieving the desired outcome has been challenging.
This is the current Javascript function:
//function to show transparent image
function ShowTransparentImage(){
//reduce opacity of firstDIV, secondDIV, and thirdDIV to 50%
document.getElementById("firstDIV").setAttribute("style","opacity:0.5; -moz-opacity:0.5; filter:alpha(opacity=50)");
document.getElementById("secondDIV").setAttribute("style","opacity:0.5; -moz-opacity:0.5; filter:alpha(opacity=50)");
document.getElementById("thirdDIV").setAttribute("style","opacity:0.5; -moz-opacity:0.5; filter:alpha(opacity=50)");
//increase opacity of masterDiv's background image to 50%
document.getElementById("masterDIV.background-image").setAttribute("style","opacity:0.5; -moz-opacity:0.5; filter:alpha(opacity=50)");
};
The challenge lies in properly manipulating the overlapping images through CSS changes within the Javascript function. Any assistance or guidance on how to tackle this issue would be greatly appreciated. Thank you!