I have asp.net C# web app. it has country dropdownlist.when the page load I want to select current users country. how can I do this? :rolleyes:
aish 0 Light Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
Here is nice example how to do something like that, if you are happy to read the code :cheesy:
http://www.creative.com/language.asp
aarya 1 Junior Poster
i i m giving the coding this is the example of indian states.
change according to ur requirment
<FORM ACTION="your.php" onsubmit="return validform();" name="login" method="POST" >
<SCRIPT src="jsTester.js" type=text/javascript></SCRIPT>
<TD class=style12>*State<img src="spacer.gif" width=45 height=10>
<SELECT class=DropList
id=req_select-one_State style="WIDTH: 160px"
onchange=SetCityDropDown(this.form.name);
name=State><option value="" selected>select</option><OPTION value="all"> all</OPTION><OPTION
value="Andaman and Nicobar">Andaman and
Nicobar</OPTION><OPTION
value="Andhra Pradesh">Andhra
Pradesh</OPTION><OPTION
value="Arunachal Pradesh">Arunachal
Pradesh</OPTION><OPTION
value=Assam>Assam</OPTION><OPTION
value=Bihar>Bihar</OPTION><OPTION
value=Chandigarh>Chandigarh</OPTION><OPTION
value=Chattisgarh>Chattisgarh</OPTION><OPTION
value=Daman>Daman</OPTION><OPTION
value=Delhi>Delhi</OPTION><OPTION
value=Diu>Diu</OPTION><OPTION
value=Goa>Goa</OPTION><OPTION
value=Gujarat>Gujarat</OPTION><OPTION
value=Haryana>Haryana</OPTION><OPTION
value="Himachal Pradesh">Himachal
Pradesh</OPTION><OPTION
value="Jammu Kashmir">Jammu
Kashmir</OPTION><OPTION
value=Jharkhant>Jharkhant</OPTION><OPTION
value=Karnataka>Karnataka</OPTION><OPTION
value=Kerala>Kerala</OPTION><OPTION
value=Lakshadeep>Lakshadeep</OPTION><OPTION
value=MadhyaPradesh>MadhyaPradesh</OPTION><OPTION
value=Maharashtra>Maharashtra</OPTION><OPTION
value=Manipur>Manipur</OPTION><OPTION
value=Meghalaya>Meghalaya</OPTION><OPTION
value=Mizoram>Mizoram</OPTION><OPTION
value=Nagaland>Nagaland</OPTION><OPTION
value=Orissa>Orissa</OPTION><OPTION
value=Pondicherry>Pondicherry</OPTION><OPTION
value=Punjab>Punjab</OPTION><OPTION
value=Rajasthan>Rajasthan</OPTION><OPTION
value=Sikkim>Sikkim</OPTION><OPTION
value="Tamil Nadu">Tamil Nadu</OPTION><OPTION
value=Tripura>Tripura</OPTION><OPTION
value="Uttar Pradesh">Uttar
Pradesh</OPTION><OPTION
value=Uttaranchal>Uttaranchal</OPTION><OPTION
value="West Bengal">West
Bengal</OPTION></SELECT><INPUT type=hidden
name=HiddenCity></TD></TR>
<TR>
<TD colSpan=2 height=3></TD></TR>
<TR>
<TD class=style12>*City<img src="spacer.gif" width=52 height=10>
<SELECT class=DropList
id=req_select-one_City style="WIDTH: 160px"
name=City> <option value="" selected>select</option><OPTION value="all">all
</OPTION></SELECT> </TD></TD>
:mrgreen: this is jstester.js
function SetCityDropDown(form){var State=new Array;State['all']=new Array("all","all");State['Tamil Nadu']=new Array (
"all","all", "Chennai","1","Coimbatore","2","Madurai","3","Trichy","4","Salem","5","Tiruppur","6","Tirunelveli","7","Erode","8","Vellore","9","Thoothukkudi","10","Thanjavur","11","Nagercoil","12");
State['Andhra Pradesh']=new Array ("all ","all","Anantapur","36","Cuddapah","37","Eluru","38","Guntur","39","Hyderabad","40","Kakinada","41","Kurnool","42",
"Karimnagar","43","Nellore","44","Nizamabad","45","Rajahmundry","46","Ramagundam","47","Tirupati","48","Visakhapatnam","49","Vijayawada","50","Warangal","51");
State['Assam']=new Array ("all ","all","Guwahati","52","Silchar","53");
State['Bihar']=new Array ("all ","all","Arrah","54","Bhagalpur","56","Darbhanga","57","Gaya","58","Muzaffarpur","59","Patna","60");
State['Chhattisgarh']=new Array ("all","all","Bhilai","61","Bilaspur","62","Korba","63","Raipur","64");
State['Gujarat']=new Array ("all","all","Ahmedabad","65","Bhaunagar","66","Junagadh","67","Jamnagar","68","Navsari","69","Rajkot","70","Surat","71","Surendranagar","71","Vadodara","73");
State['Haryana']=new Array ("all ","all","Faridabad","74","Gurgaon","73","Hisar","76","Karnal","77","Panipat","78","Rohtak","79","Sonipat","80","Yamunanagar","81","Panchkula","255");
State['Himachal Pradesh']=new Array ("all","all","Simla","82");
State['Jammu Kashmir']=new Array ("all","all","Jammu","83","Srinagar","84");
State['Karnataka']=new Array ("all","all","Bangalore","85","Hubli","86","Dharwar","87","Mysore","88","Mangalore","89",
"Belgaum","90","Gulbarga","91","Davanagere","92","Bellary","93","Shimoga","94","Bijapur","95","Tumkur","96","Raichur","97");
State['Kerala']=new Array ("all","all","Kochi","98","Thiruvananthapuram","99","Kozhikode","100",
"Thalassery","101","Kollam","102","Thrissur","103","Alappuzha","104","Palakkad","105");
State['MadhyaPradesh']=new Array ("all","all","Indore","106","Bhopal","107","Jabalpur","108","Gwalior","109","Ujjain","110","Sagar","111",
"Ratlam","113","Dewas","114","Satna","115");
State['Maharashtra']=new Array ("all ","all","Mumbai","116","Pune","117","Nagpur","118","Nasik","119","Shambajinagar","120","Solapur","121","Bhiwandi","122","Amravati","123","Kolhapur","124","Sangli","125","Nanded","126","Malegaon","127","Akola","128","Jalgaon","129","Dhule","130","Latur","131","Chandrapur","132","Ichalkaranji","133","Parbhani","134","Jalna","135");
State['Manipur']=new Array ("all","all","Imphal","136");
State['Meghalaya']=new Array ("Select One","","Shillong","137");
State['Mizoram']=new Array ("all","all","Aizawl","138");
State['Nagaland']=new Array ("all","all","Dimapur","139");
State['Orissa']=new Array ("all","all","Bhubaneswar","140","Cuttack","141","Rourkela","142","Berhampur","143","Sambalpur","144");
State['Punjab']=new Array ("all ","all","Ludhiana","145","Amritsar","146","Jalandhar","147","Patiala","148","Bathinda","149");
State['Rajasthan']=new Array ("all ","all","Jaipur","150","Jodhpur","151","Kota","152","Bikaner","153","Ajmer","154",
"Udaipur","155","Bhilwara","156","Alwar","157","Ganganagar","158","Bharatpur","159");
State['Sikkim']=new Array ("all","all","Gangtok","160");
State['Tripura']=new Array ("all","all","Agartala","161");
//State['Uttaranchal']=new Array ("all","all","DehraDun","162","Hardwar","163");
State['Uttar Pradesh']=new Array ("all","all","Uttar pradesh","164","Kanpur","165","Lucknow","166",
"Agra","167","Varanasi","168","Meerut","169","Allahabad","170","Ghaziabad","171",
"Bareilly","172","Aligarh","173","Moradabad","174","Gorakhpur","175","Jhansi","176","Saharaanpur","177",
"Firozabad","178","Muzaffarnagar","179","Shahjahanpur","180","Mathura","181","Rampur","182","Farrukhabad","180",
"Hapur","183","Etawah","184","Maunath Bhanjan","185","Noida","214");
State['West Bengal']=new Array ("all ","all","Kolkata","186","Asansol","187","Durgapur","188","Shiliguri","189","Kharagpur","190","Barddhaman","191");
State['Andaman and Nicobar']=new Array ("all","all","Andaman and Nicobar","192");
State['Delhi']=new Array ("all","all","Delhi","193");
State['Diu']=new Array ("all","all","Diu","194");
State['Daman']=new Array ("all","all","Daman","195");
State['Goa']=new Array ("all","all","Goa","196");
State['Lakshadeep']=new Array ("all","all","Lakshadeep","197");
State['Pondicherry']=new Array ("Select One","","Pondicherry","198");
State['Arunachal Pradesh']=new Array ("all","all","Itanagar","199","Changlang","200","Dibang Valley","201","Kameng","202","Kurung Kumey","203","Lohit","204","Subansiri","205","Papum Pare","206","Siang","207","Tawang","208","Tirap","209");
State['Jharkhant']=new Array ("all ","all","Jamshedpur","210","Dhanbad","211","Ranchi","212","Bokaro","213");
State['Chandigarh']=new Array ("all","all","Chandigarh","220");
State['Uttaranchal']=new Array ("all","all","Dehradun","300","Haldwani","301","roorkee","302","Hardwar","303");
State['Chattisgarh']=new Array ("all","all","Bhilai","310","Bilaspur","311","Raipur","312");
Edited by TrustyTony because: fixed formating
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.