Normally In form country State District create in Ajax
In This case we have create in JavaScript
Create one file name as dynamic.php
<html>
<head>
<script type=”text/javascript”>
function p() //when select contry this function exicute
{
var s1=document.getElementById(‘select1’).value;//get id of select1 tag
var s2=document.getElementById(‘select2’);//get id of select2 tag
if(s1 == “india”)
{
var state=[“Gujrat”,”MP”];
}
if(s1 == “canada”)
{
var state=[“TY”,”FGGH”];
}
for(var i=0;i<state.length;i++)
{
var newoption=document.createElement(“option”);//create option variable of select
newoption.value = state[i]; //set value of option
newoption.innerHTML = state[i]; //set tagname of option
s2.options.add(newoption); //add value and tag name of option
}
}
function p1()//when select state this function exicute
{
var s2=document.getElementById(‘select2’).value;
var s3=document.getElementById(‘select3’);
if(s2 == “Gujrat”)
{
var dis=[“Surat”,”Vapi”,”Baroda”];
}
if(s2 == “MP”)
{
var dis=[“Indor”,”Bhopal”];
}
for(var i=0;i<dis.length;i++)
{
var newoption=document.createElement(“option”);
newoption.value=dis[i];
newoption.innerHTML=dis[i];
s3.options.add(newoption);
}
}
</script>
</head>
<body>
<center>
<h2>Contry State District</h2>
<select id=”select1″ name=”select1″ onChange=”p()”>
<option value=””>Country</option>
<option value=”india”>India</option>
<option value=”canada”>Canada</option>
</select>
<select id=”select2″ name=”select2″ onChange=”p1()”>
<option value=””>State</option>
</select>
<select id=”select3″ name=”select3″>
<option value=””>District</option>
</select>
</center>
</body>
</html>
O/P