I am trying to set a javascript global var using jquery and dynamic variable names like this:
var home_phone_number // located outside of any functions
.
.
.
function setPhoneVars(phone){
// do stuff here to determine the correct prefix
thePrefix = 'home_phone_'
$(thePrefix + "number").val(phone.number);
}
When I do this, the value of home_phone_number is undefined.
But, when I set the phone number manually, like this:
home_phone_number = phone.number
the variable is set as expected.
$(thePrefix + "number")Will look for an HTML element like<home_phone_number>