Re: dynamic drop down

From: Date: Tue, 23 Apr 2002 11:56:12 +0000
Subject: Re: dynamic drop down
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-94139@lists.php.net to get a copy of this message
Hi Kunul, I think I have code that does what you want: -------------------------------------------------------------------- function QuickJumpSelect($name="", $optionvalues, $optionnames, $stylestr="") { ($stylestr != "")? $style = $stylestr : $style = ""; // Calculate stuff $count = count($optionnames); $output = ""; // -- Start outputting the SELECT -- $output .= "<SELECT NAME=\"$name\"$style $size OnChange=JumpToRef(this)>"; $output .= "<option value=\"\">Jump to:</option>\n"; for($idx = 0; $idx < $count; ++$idx){ $name = $optionnames[$idx]; $val = trim($optionvalues[$idx]); $output .= "<option value=\"$val\">$name</option>\n"; } $output .= "</SELECT>\n"; return $output; } // - end function --------------------------------------------------- Call it like this: $JumpPad = QuickJumpSelect("EenieMeenieMinyMoe", $array_of_urls, $array_of_names_to_show_in_list, $stylestring); stylestring is a CSS argument, like: $stylestring = "style=\"width: 100px; font-family: Arial; font-size: 10px\""; Now you can just print $JumpPad where you want it to be. --------------------------------------------------- All the best, Eivind :-)

« previous php.general (#94139) next »