Saturday, 25 May 2013

combo box using javascript or select state and corrensepondence cities

COMBO BOX OR SELECT STATE AND CORRESEPONDENCE CITIES

Below given simple and easy code to create combo box :

Code :


<script>
function com()
{
   if(document.f1.state.value==1)
   {
   //alert("hello");
   document.getElementById("demo").innerHTML="<select><option>mohali</option><option>jalandhar</option></select>";
   document.f1.state.value.focus();
   return true;
   }

   if(document.f1.state.value==2)
   {
   //alert("hello");
   document.getElementById("demo").innerHTML="<select><option>jaipur</option><option>ajmer</option></select>";
   document.f1.state.value.focus();
   return true;
   }

   if(document.f1.state.value==3)
   {
   //alert("hello");
   document.getElementById("demo").innerHTML="<select><option>lucknow</option><option>aligarh</option></select>";
   document.f1.state.value.focus();
   return true;
   }
}
</script>
<form action="" method="post" name="f1">
<select name="state" onchange="com()">
<option value="">Select State</option>
<option value="1">panjab</option>
<option value="2">rajsthan</option>
<option value="3">up</option>
</select>
<p id="demo"></p>
</form>


Output of above code :







No comments:

Post a Comment