I’m trying to write a function, which calls a value out of a defined array:
var categories = [];
categories[caller1] = "asasd";
categories[caller2] = "asasd";
categories[caller3] = "asasd";
function getNewItem(caller){
$("#"+categories[caller]).show();
}
So the basic problem is, that this doesn’t work:
function(VARIABLE){
$("#"+ categories[VARIABLE]).show();
}
This code is reduced to the minimum to show the problem.
I would like to see what caller1, caller2, and caller3 are defined as. I’m assuming, as I’m sure we all are, that they are integers. As such, it would look something like this:
But my other assumption is that they might be strings, in which case you’re doing this all wrong. Use an object instead of an array.
But this could even be extended to functions and numbers as well: