PHP - Color picker example


SUBMITTED BY: efbee

DATE: Oct. 5, 2016, 7:01 p.m.

FORMAT: PHP

SIZE: 1.5 kB

HITS: 1031

  1. Color picker
  2. <?
  3. for ($red_channel=0;$red_channel<=15;$red_channel=$red_channel+3)
  4. {
  5. for ($green_channel=0;$green_channel<=15;$green_channel=$green_channel+3)
  6. {
  7. for ($blue_channel=0;$blue_channel<=15;$blue_channel=$blue_channel+3)
  8. {
  9. $red_channel_value=dechex($red_channel).dechex($red_channel);
  10. $green_channel_value=dechex($green_channel).dechex($green_channel);
  11. $blue_channel_value=dechex($blue_channel).dechex($blue_channel);
  12. @$index_pointer++;
  13. $hex_values_table[$index_pointer]=$red_channel_value.$green_channel_value.$blue_channel_value;
  14. }
  15. }
  16. }
  17. $index_pointer=1;
  18. echo "<table>";
  19. for ($x=1;$x<=15;$x++)
  20. {
  21. echo "<tr>";
  22. for ($y=1;$y<=15;$y++)
  23. {
  24. $display_value=@$hex_values_table[$index_pointer];
  25. if (!$display_value)$display_value="ffffff";
  26. echo "<a href='colorselect.php?color=$display_value' alt='$display_value' title='$display_value'><td title='$display_value' alt='$display_value' style='cursor:pointer;cursor:hand;' width=20px height=20px alt='$display_value' bgcolor=$display_value></td></a>";
  27. $index_pointer++;
  28. }
  29. echo"</tr>";
  30. }
  31. echo "</table>";
  32. if (@$link_submitted_value=@$_REQUEST['color']) echo "You have selected:<br> Hexadecimal Color [$link_submitted_value]<table><tr><td width=356px height=25px bgcolor=$link_submitted_value></td></tr></table>";;
  33. ?>

comments powered by Disqus