i was searching Enum usage in javascript. i found one stackoverflow link Enums in JavaScript? it is good start.
this link show one good use like
var SIZE = {
SMALL : {value: 0, name: "Small", code: "S"},
MEDIUM: {value: 1, name: "Medium", code: "M"},
LARGE : {value: 2, name: "Large", code: "L"}
};
var currentSize = SIZE.MEDIUM;
if (currentSize == SIZE.MEDIUM) {
// this alerts: "1: Medium"
alert(currentSize.value + ": " + currentSize.name);
}
my requirement was bit different and that why i change the above code like
var MSg = {
Country= {
GBR: {name_req:"Name Required",email_req:"Email Required"},
FRA: {name_req:"FRA Name Required",email_req:"FRA Email Required"}
}
};
but it is giving error. so please guide me how to write the above code without error. also tell me the enum code will work in all the browser? thanks.
For my own future references
var dialog =
{
MainContainer:
{
Country:
{
GBR:
{
height: 365, width: 257
},
FRA:
{
height: 375, width: 310
}
}
},
SubContainer:
{
Country:
{
GBR:
{
height: 0, width: 257
},
FRA:
{
height: 0, width: 300
}
}
}
};
var Validation =
{
Msg:
{
Country:
{
GBR:
{
Name: "Name Required",
Subject: "Subject Required",
Email: "Email Required",
Invalid_Email: "Invalid Email Address",
Feedback: "Feedback details Required",
Success: "Feedback send successfully",
Fail: "Feedback send fail"
},
USA:
{
Name: "Name Required",
Subject: "Subject Required",
Email: "Email Required",
Invalid_Email: "Invalid Email Address",
Feedback: "Feedback details Required",
Success: "Feedback send successfully",
Fail: "Feedback send fail"
}
}
}
};
assignment or set country
var feedCookie = getCookie('SetCountry');
feedCookie = (feedCookie == '' ? 'GBR' : feedCookie);
var dialog_Main = dialog.MainContainer.Country[feedCookie];
var dialog_Sub = dialog.SubContainer.Country[feedCookie];