Is there a way to make the output of my string be interpreted as a variable rather than displayed as text?
Despite researching the issue, I am struggling to find a solution as a beginner in this subject.
}
function showDetailedView(currentDiv) {
var popframe = document.getElementById(currentDiv);
var picture = currentDiv.substring(0, currentDiv.length - 5);
var pic1 = "Arachnobot mk II";
var pic2 = "Tyson Droid";
var pic3 = "Dancer Bot";
var pic4 = "Skinny Fingers";
var pic5 = "Abomination";
var pic6 = "Dog";
var pic7 = "Smart Scratch";
var pic8 = "Soccer Bots";
var pic9 = "Butler Bot";
var pic10 = "Peanut Gallery";
var pic11 = "Statue Bot";
var pic12 = "Gang Boys";
var pic13 = "Nuclear Machine of Mass Destruction";
var pic14 = "Eye Roll Droid";
var pic15 = "Pet";
popping = popframe.id;
popframe.id = "popout";
popframe.innerHTML = "<br /><TABLE><TR><TH rowspan='3'><img
src='http://" + window.location.hostname +
"/aprilla/"+currentDiv.substring(0,
currentDiv.length - 5)+".jpg' width='250'><TH align='left'>Robot Type:
<TH align='left'>" +
currentDiv.substring(0, currentDiv.length -
5)+ "<TR><TH align='left'>Description: <TH align='left'> 'They do robot
stuff' <TR></TABLE> ";
var nameholder = "popout";
var unpopped = document.getElementById(nameholder);
unpopped.onmouseout = hideDetailedView;
}
The expected behavior was for
currentDiv.substring(0, currentDiv.length - 5)+
to return values like pic1
, pic2
, pic3
, etc. which would then correspond to predefined variable names such as pic1
corresponding to Arachnobot mk II
and so on. However, instead of converting to the respective variables, it simply displays the text pic1
, pic2
, pic3
, etc.