I want the output of my string to be read as a variable and not printed as text
I have tried to research the problem, but as an introductory student I can't really find what i'm looking for
}
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;
}
I expected currentDiv.substring(0, currentDiv.length - 5)+
to output the value pic1
, pic2
, pic3
, etc. based on the image that I'm mousing over, then, based on the possible outputs, it would correspond to one of the hard-coded variable names to produce the final product of Robot Type: Arachnobot mk II
if hovering over pic1
, or Robot Type: Butler Bot
if hovering over pic 9
. Instead of this result it just outputs the text pic1
, pic2
, pic3
, etc. and doesn't convert it into the corresponding variables.