10-30-2003, 06:53 PM
| THREAD STARTER
#1 (permalink)
|
| Senior Member Join Date: Aug 2002
Posts: 1,255
| A simple function to create numbered or alphabetical drop down menus in PHP This is a simple and/or silly  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. ????: NamePros.com http://www.namepros.com/code/15483-simple-function-create-numbered-alphabetical-drop.html PHP Code: <?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.
//webmaster@webdesigntalk.net
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
????: NamePros.com http://www.namepros.com/showthread.php?t=15483 //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);
?> |
| |