IT.COM

A simple function to create numbered or alphabetical drop down menus in PHP

NameSilo
Watch
Impact
6
This is a simple and/or silly :D little function to create numbered or alphabetical dropdown menus. It could be useful if you needed to create alot of them on one page. I threw it together quickly so I'm sure it could be improved. It takes three arguments, name, startcount, and limit. name is the only required argument.
PHP:
<?php
        // 
       //
      //Code by deadserious - © 2003 http://www.webdesigntalk.net
     //THIS CODE IS FREEWARE AND CAN BE USED FOR BOTH 
    //COMMERCIAL AND NON-COMMERCIAL USE. REPUBLICATION
   //OF THE CODE REQUIRES OUR PERMISSION. 
  //[email protected]


    function dropdown ( $name, $count = 97, $limit = 122 ) {
     echo "t<select name="$name">n";
      for ($i=$count; $i<=$limit; $i++) {
       if ($count == 1) {
         echo "tt<option>$i</option>n";
       } else {
         echo "tt<option>" . chr($i) . "n";
       }
      }
     echo "t</select>n";
    }

//useage for numbered dropdown counting from 1 to 50:


dropdown(rows,1,50);


//for numbered dropdown counting from 1 to 25:


dropdown(mydropdown,1,25);


//useage for alphabetical dropdown from a to z, just put in the name
//This drop down has the name of alphadrop, nothing else is necessary:


dropdown(alphadrop);


//for alphabetical dropdown listing from a to k
//a starts at 97 and ends at 122 so you'll have to  do
//some thinking to determine which number to go to :-)


dropdown(newdrop,97,107);

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back