I have five possible buttons to push and each of these buttons runs the same function. But I would also like that button push to make a unique global variable too. A variable that says "this button was pushed so add this "word" where ever needed.
document.getElementById("One").addEventListener("click", Variables);
document.getElementById("Two").addEventListener("click", Variables);
document.getElementById("Three").addEventListener("click", Variables);
document.getElementById("Four").addEventListener("click", Variables);
document.getElementById("Five").addEventListener("click", Variables);
So they all run exactly the same function but the "One" or "Two" or "Three" string needs to become a global variable. I later use these to make some numbers:
For example I would use "One" to make one of these outcomes:
if (mapNumber = "One" || "Three" || "Four") {
climate = ["dry", "light rain", "medium rain", "heavy rain", "light snow", "medium snow", "heavy snow", "light ice", "very icy", "severe ice"];
I am at a bit of a loss on how to call this to make it a global. I tried making a function inside the function but it seemed to cause the other function to stop. So I am guessing I have made a syntax error somewhere.
I tried doing an onclick="myFunction(this.id)" function as well as the EventListener but this didn't seem to work either.
A pointer in the right direction would definitely be helpful. I have done searches, but these all seem to produce local variables at best.
Thanks :)
if (mapNumber = "One" || "Three" || "Four")is wrong on multiple levels