The code should show the plot for the book cover you click on whilst changing the background to an alternative cover of the book, but it isn't doing anything. I have some backup code that works, but I liked this solution more.
My js code:
function mostraTrama(){
try{
switch(this.id){
case "TramaVdR":
nodoTramaVdR.setAttribute = ("class", "TramaScelta");
nodoTramaPdL.setAttribute = ("class", "TramaNonScelta");
nodoTramaG.setAttribute = ("class", "TramaNonScelta");
document.body.style.backgroundImage = "url('../Images/way_of_kings_bg.jpg')";
break
case "TramaPdL":
nodoTramaVdR.setAttribute = ("class", "TramaNonScelta");
nodoTramaPdL.setAttribute = ("class", "TramaScelta");
nodoTramaG.setAttribute = ("class", "TramaNonScelta");
document.body.style.backgroundImage = "url('../Images/words_of_radiance_bg.jpg')";
break
case "TramaG":
nodoTramaVdR.setAttribute = ("class", "TramaNonScelta");
nodoTramaPdL.setAttribute = ("class", "TramaNonScelta");
nodoTramaG.setAttribute = ("class", "TramaScelta");
document.body.style.backgroundImage = "url('../Images/oathbringer_bg.jpg')";
break
}
}
catch(e){
alert("mostraTrama " + e);
}
}
function gestoreLoadRomanzi(){
try {
nodoTramaViaDeiRe = document.getElementById("TramaViaDeiRe");
nodoTramaParoleDiLuce = document.getElementById("TramaParoleDiLuce");
nodoTramaGiuramento = document.getElementById("TramaGiuramento");
nodoTramaVdR = document.getElementById("TramaVdR");
nodoTramaPdL = document.getElementById("TramaPdL");
nodoTramaG = document.getElementById("TramaG");
nodoTramaViaDeiRe.onclick = mostraTrama;
nodoTramaParoleDiLuce.onclick = mostraTrama;
nodoTramaGiuramento.onclick = mostraTrama;
} catch ( e ) {
alert("gestoreLoadRomanzi " + e);
}
}
All three start off with class = "TramaNonScelta", which has display: none, and when clicked they should change to class = "TramaScelta", which has display: inline. The IDs all match to the ones they have in the HTML document.
My alternate functioning way is to have a separate function for each book instead of a single one for all of them.
EDIT: I also have a very similar code for another program that instead of using .setAttribute uses .innerHTML and works without any problems (but my professor doesn't want us to use .innerHTML in this project)