Location: PHPKode > scripts > Color Picker > color-picker/class_color_picker.php
<?
##############################################
#
#	FREE FOR USE:
#	
#	$my_picker = new color_picker();
#
#	$my_picker->print_select(); // OR:
#	$my_picker->print_radio(); 
#
#	Author: Rafa³ Lidwin
#	hide@address.com
#	http://www.lidwin.pl
#
#	
#
##############################################

class color_picker{
	var $name;
	var $first_option;

	var $kolor_arr = array(
		"#FFFFFF, <font color=black>bia³y (white)</font>",
		"#c0c0c0, jasnoszary (silver)", 
		"#4c4c4c, ciemnoszary (gray)", 
		"#ccccff, fioletowy",
		"#9966cc, purpurowy",
		"#ccffff, bladozielony",
		"#00cccc, turkusowy",
		"#008000, zielony",
		"#0099ff, niebieski",
		"#0066cc, lazurowy",
		"#0000ff, b³êkitny",
		"#ffff66, ¿ó³ty",
		"#ffcc99, pomarañczowy",
		"#eb613d, ciemnopomarañczowy",
		"#ff3366, ró¿owy",
		"#ff0000, czerwony",
		"#4c1900, br¹zowy",
		"#000000, czarny"
	);
	function color_picker($name = "my_color", $firts_option = "select color..."){
		$this->name = $name;
		$this->first_option = $firts_option;
	}

	function print_radio(){
		echo $this->first_option."<br>\n\n";
		for($i=0;$i<count($this->kolor_arr);$i++){
			$wiersz = explode(",",$this->kolor_arr[$i]);
			$value = $wiersz[0];
			$color = $wiersz[1];
			echo "<input type=\"radio\" name=\"".$this->name."\" value=\"".$value."\"><font color=\"".$value."\">".$color."</font><br>\n";
		}
	}
	function print_select(){
		echo "<select name=\"".$this->name."\">\n";
		echo "<option value=\"\">".$this->first_option."</option>\n";
		for($i=0;$i<count($this->kolor_arr);$i++){
			$wiersz = explode(",",$this->kolor_arr[$i]);
			$value = $wiersz[0];
			$color = $wiersz[1];
			echo "<option value=\"".$value."\" style=\"background-color:".$value."\">".$color."</option>\n";
		}
		echo "</SELECT>\n\n";
	}
}

?>
Return current item: Color Picker