var tmp = "";
function putItem()
{
this.innerHTML = "<img src = 'image/"+tmp+".png'>";
}
I also have a td that calls this
<img src = 'images/wood.png' onclick = 'tmp = "wood";'>
<td onclick = "grid1 = tmp; checkEmpty(); putItem(this);">
I tested it by making the "<img src = 'image/"+tmp+".png'>"; a variable and when I returned what the variable was when tmp wasnt an empty string it came out as "<img src = 'image/.png'>" ie it ignored the tmp.
Any help?
I’m trying to make the “Minecraft (c) Crafting Table” for a web dev project
Question changed. Now it seems that the only issue is that you need to use
.callto set thethisvalue inputItem.Original answer
I assume instead of this…
You want this…
So now you’re assigning the
"grid1"string to thetmpvariable, and when you callputItem(), you’re using.callto set itsthisvalue.That said, instead of using a global variable, why not just pass the string?