Introduction:-
Step:1 The designing code goes here.
<html>
<script type= "text/javascript">
function fun(cc)
{
var s=document.myform.cities;
s.options.length=0;
if(cc=="")
{
s.options[s.options.length]=new Option('please select of any item ','');
}
else if(cc=="1")
{
s.options[s.options.length]=new Option('jaipur','');
s.options[s.options.length]=new Option('delhi','');
}
else if(cc=="2")
{
s.options[s.options.length]=new Option('nagashakhi','');
s.options[s.options.length]=new Option('hiroshima','');
}
else if(cc=="3")
{
s.options[s.options.length]=new Option('karachi','');
s.options[s.options.length]=new Option('multan','');
}
}
</script>
<body style="border:5px groove #249fa3; width: 391px; height: 111px; margin-left: 471px;">
<form name="myform">
<div align="center" style="padding-top:8px">
<select name="option"size="1"onchange="fun(this.value);">
<option value="0">--Select-- </option>
<option value="1">INDIA </option>
<option value="2">JAPAN </option>
<option value="3">PAKISTAN</option>
</select>
<select name="cities"size="1">
<option value="0">--City-- </option>
</select>
</div>
</form>
</body>
</html>
Demo :-
Hii Friends....
Today I explain how to fill a dropdown by click on other dropdown like we have two dropdowns one is for countries and second for cities and we want to fill city dropdown on the bases of country dropdown automatically fill.
Today I explain how to fill a dropdown by click on other dropdown like we have two dropdowns one is for countries and second for cities and we want to fill city dropdown on the bases of country dropdown automatically fill.
<html>
<script type= "text/javascript">
function fun(cc)
{
var s=document.myform.cities;
s.options.length=0;
if(cc=="")
{
s.options[s.options.length]=new Option('please select of any item ','');
}
else if(cc=="1")
{
s.options[s.options.length]=new Option('jaipur','');
s.options[s.options.length]=new Option('delhi','');
}
else if(cc=="2")
{
s.options[s.options.length]=new Option('nagashakhi','');
s.options[s.options.length]=new Option('hiroshima','');
}
else if(cc=="3")
{
s.options[s.options.length]=new Option('karachi','');
s.options[s.options.length]=new Option('multan','');
}
}
</script>
<body style="border:5px groove #249fa3; width: 391px; height: 111px; margin-left: 471px;">
<form name="myform">
<div align="center" style="padding-top:8px">
<select name="option"size="1"onchange="fun(this.value);">
<option value="0">--Select-- </option>
<option value="1">INDIA </option>
<option value="2">JAPAN </option>
<option value="3">PAKISTAN</option>
</select>
<select name="cities"size="1">
<option value="0">--City-- </option>
</select>
</div>
</form>
</body>
</html>
Demo :-
0 comments:
Post a Comment