March 2010
M T W T F S S
« Dec   Apr »
1234567
891011121314
15161718192021
22232425262728
293031  

Set dropdownlist

function setDropDownList(elementRef, valueToSetTo)
{
var isFound = false;

for (var i = 0; i < elementRef.options.length; i++)
{
if (elementRef.options[i].value == valueToSetTo)
{
[...]

Add, remove event in Google map

// add

var map = new GMap2(document.getElementById(”map”));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
GEvent.addListener(map, “click”, function() {
alert(”You clicked the map.”);
});

// remove

function MyApplication() {
this.counter = 0;
this.map = new GMap2(document.getElementById(”map”));
this.map.setCenter(new GLatLng(37.4419, -122.1419), 13);
var myEventListener = GEvent.bind(this.map, “click”, this, function(overlay, latlng) {
if (this.counter == 0) {
[...]

String.Format() In JavaScript like C#

function StringFormat(str)
{

for (i = 1; i < arguments.length; i++)
{
str = str.replace(’{’ + (i – 1) + ‘}’, arguments[i]);
}
return str;
}

example using:
var greeting = format(‘Hello {0} & {1} ‘, ‘John’, ‘Jane’);

ref: http://xneuron.wordpress.com/2006/09/29/stringformat-in-javascript-as-in-c/