January 20 2013

Jquery Static Array

Tagged Under : ,

jquery
Use a short code to get a value from the database the easy way is using Ajax.

But the short code and value are fixed, we keep it in database is for future reuse it.

So I use another way to get the value. That is an array. use array key find the value.

Below is an example static array:
var foo = {
	my: "60",
	sg: "80",
	us: "50",
	au: "40",
	ng: "30",
	hk: "90",
	cn: "30",
	tw: "55",
};
Now var foo already is an array with the short code and value.

So, how we get the short code sg value? look below example:
foo['sg'];
Yes, Just like this. then you can get the value “80” and display it.

Make a Comment

*

code