Version: 1.00, by Slynderdale
Developer Last Online: Nov 2023
Version: 2.2.x
Rating:
Released: 01-20-2003
Last Update: Never
Installs: 1
No support by the author.
I recently installed the gender hack on my version 2.2.9 forum and looked through adminfunction.php and couldnt find a function to make a select menu si i made my own and figured I'll release it in case it would be helpful to others, any ways, here it is:
PHP Code:
// ###################### Start makeselectcode #######################
function makeselectcode ($title,$name,$selectarray,$value="select_null") {
// Makes code for select menu's
unset($content);
if (count($selectarray)) {
$content = "<select name='".$name."'>\n";
while (list($select_name,$select_value) = each($selectarray)) {
if ($select_name) {
unset($selected);
if ((trim(strtolower($select_value)) == trim(strtolower($value))) and $value != "select_null")
$selected = " selected";
$content .= '<option value="'.$select_value.'"'.$selected.'>'.$select_name.'</option>\n';
}
}
$content .= "</select>";
}
echo "<tr class='".getrowbg()."' valign='top'>\n<td><p>$title</p></td>\n<td><p>".$content."</p></td>\n</tr>\n";
}
just place that in adminfunctions.php, like above the ?>
The first parameter in the function is the title of the select menu, the secton param is the select name, the third is an array to male the select menu with, heres how that is set up:
and the forth and final param is the value of the select menu, as it creates the select menu, if the value in the array matches the value param, it selected it like:
Originally posted by Boofo Could this be made to use in other areas of the board, too, and not just the Admin area?
Yea, I actually made a function for that, i just edited for adminfunctions.php, heres the other:
PHP Code:
function createselectmenu($name,$selectarray,$value="select_null") {
unset($content);
if (count($selectarray)) {
$content = "<select name=".$name.">\n";
while (list($select_name,$select_value) = each($selectarray)) {
if ($select_name) {
unset($selected);
if (substr($select_name,0,1)=="@" or (trim(strtolower($select_value)) == trim(strtolower($value))) and $value != "select_null")) {
if (substr($select_name,0,1)=="@") $select_name = substr($select_name,1,strlen($select_name));
$selected = " selected";
}
$content .= '<option value="'.$select_value.'"'.$selected.'>'.$select_name.'</option>\n';
}
}
$content .= "</select>\n";
}
if ($content) return $content;
else return false;
}
This works the same as the one i posted before but you dont give it a title, this just outputs the select html code and thats all so you can place it any wheres. Theres two ways you can have it select a value, one is like below, have the $value param in the function the same value of in the array or add a @ in front of the name in the array like: