Create Drop Down List Script

Create Drop Down List Script is use to when you type the data at text box in with separate comma will be create drop down list.

Demo :



Array Item :  

Example :

Just type a data at text box like this A,B,C,D,F and click Create button. The drop down list will be display on the same page in below of text box.

Code :

Following code is use to Create Drop Down List core code if you need to copy and use to your website.


<script>
function validate()
{
  if(document.frm.drop_down_input.value=='')
  {
    alert('Please Enter Data for Drop Down List ');
    document.frm.drop_down_input.focus();
    return false;
  }
}
</script>
<?php
  $_GET[drop_down_input] = $_POST[drop_down_input];
  if (!$_POST['submit'])
  {
?>
  <form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="frm" id="frm" onsubmit="return validate()">
   Array Item :  <input name="drop_down_input" id="drop_down_input">
  <input type="submit" name="submit" value="Create">
  </form>
  <?php
  }
  else
  {
  $drop_down_input = explode(',',$_GET[drop_down_input]);
?>
  <form action="<?=$_SERVER['PHP_SELF']?>" method="get" name="frm" id="frm" onsubmit="return validate()">
  <select>
  <option selected="selected">Select</option>
   <?php
  foreach ($drop_down_input as $k=>$v)
  {
    echo "<option value=\"$k\">$v</option>\n";
  }
  ?>
  </select>
  </form>
  <?php
  }
  ?>

In the above validate() function is use to Create Drop Down List form validation.

Free Download Script :

If you need Create Drop Down List Script click and download from following link.

Download




Content