So I am trying to create a variable that grabs the type_name from an array.
Here is my array.
var customIcons = {
ItemI: {
icon: 'http://...'
type_name: 'East'
},
ItemII: {
icon: 'http://...'
type_name: 'West'
},
ItemIII: {
icon: 'https:...'
type_name: 'North'
},
question: {
icon: 'https:...'
type_name: 'South'
}
}
Here is the variable I am trying to create. I know the php is passing in correctly, but I do not know why it is not grabbing the appropriate type_name from the array:
var buttonText= customIcons[<?php echo $type; ?>].type_name;
I am getting a cannot read property 'type_name' of undefined when I try to use the variable.
Sincere thanks for any help! It is greatly appreciated.