This has been bugging me for quite some time now. All I want to do is return a value from an array given its key, but use a variable (_interview) to choose what array to return from.
var utils = function () {
var _language = "";
var _interview = "";
var _base = "";
var _alerts = function (code) {
var en = new Array(),
fr = new Array();
en[0] = "You must enter a value in the box before continuing.";
fr[0] = "Vous devez entrer une sélection pour les options mises en évidence.";
// I know _interview is returning the correct value of either "en" or "fr"
// I have tried this[_interview][code] but I get property not defined at the index
// How do I return the index from the right array?
};
return {
lang : function () {
_language = $("#language option:selected").val();
var answer = confirm(_alerts(0)); // Call from here
}
};
}();
$(document).ready(function ()
{
utils.lang();
});