Posted by: james | July 11, 2009

change dropdown

function chng_city()
{
t = document.getElementById(“city”).value.length;
//alert(t);
var v = document.getElementById(“city”);
//alert(v);
if(t > 0)
{
for(i = 0; i < t; i++ )
{
v.remove(0);
}
}
if(document.getElementById(“state”).value == “Gujarat”)
{
var d = document.getElementById(“state”).value == “Gujarat”;
//alert(d);
//alert(t);
var v = document.getElementById(“city”);

// var x = document.getElementById(“state”);
//x.remove(0);
var s = document.createElement(‘option’);

s.text = ‘CITY’;
v.add(s,1);
var s = document.createElement(‘option’);

s.text = ‘Ahmedabad’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘Gandhinagar’;
// var x = document.getElementById(“state”);
v.add(s,1);
}
if(document.getElementById(“state”).value == “Maharstra”)
{

//alert(t);
var v = document.getElementById(“city”);

// var x = document.getElementById(“state”);
//x.remove(0);
var s = document.createElement(‘option’);

s.text = ‘CITY’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘bombay’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘thane’;
// var x = document.getElementById(“state”);
v.add(s,1);
}
if(document.getElementById(“state”).value == “calcutta”)
{

//alert(t);
var v = document.getElementById(“city”);

// var x = document.getElementById(“state”);
//x.remove(0);
var s = document.createElement(‘option’);

s.text = ‘CITY’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘calcutta1’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘calcutta2’;
// var x = document.getElementById(“state”);
v.add(s,1);
}
if(document.getElementById(“state”).value == “Banglore”)
{

//alert(t);
var v = document.getElementById(“city”);

// var x = document.getElementById(“state”);
//x.remove(0);
var s = document.createElement(‘option’);

s.text = ‘CITY’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘Banglore1’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘Banglore2’;
// var x = document.getElementById(“state”);
v.add(s,1);
}
if(document.getElementById(“state”).value == “Delhi”)
{

//alert(t);
var v = document.getElementById(“city”);

// var x = document.getElementById(“state”);
//x.remove(0);
var s = document.createElement(‘option’);

s.text = ‘CITY’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘Delhi1’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘Delhi2’;
// var x = document.getElementById(“state”);
v.add(s,1);
}
if(document.getElementById(“state”).value == “Bengal”)
{

//alert(t);
var v = document.getElementById(“city”);

// var x = document.getElementById(“state”);
//x.remove(0);
var s = document.createElement(‘option’);

s.text = ‘CITY’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘Bengal1’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘Bengal2’;
// var x = document.getElementById(“state”);
v.add(s,1);
}
if(document.getElementById(“state”).value == “Goa”)
{

//alert(t);
var v = document.getElementById(“city”);

// var x = document.getElementById(“state”);
//x.remove(0);
var s = document.createElement(‘option’);

s.text = ‘CITY’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘goa1’;
v.add(s,1);
var s = document.createElement(‘option’);
s.text = ‘goa2’;
// var x = document.getElementById(“state”);
v.add(s,1);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: