PDA

View Full Version : Color picker


Missy Master
08-24-2018, 11:23 PM
Does anyone know a simple way to use color picker with the latest version?

I want to use that to change colors on bases.



I've never gotten the hang of CP, sadly!

Dinocanid
08-26-2018, 07:12 PM
You could use a color picker with an HTML form, like:
$document->add(new Comment("<form action='PAGENAME' method='post'>
<input type='color' id='color' name='color' value='#e66465' />
<button id='submit' value='submit' name='submit type='submit'>Pick Color!</button>
</form>"));
Replace PAGENAME with the whatever page you use this on. If used in blankview.php for example, you would replace it with "blank".

To get the data from the form, use this:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$mycolor = $_REQUEST['color'];
$document->add(new Comment("The color you picked was {$mycolor}!"));
//a database statement could also go here if you want to store the chosen color
return;
}

That's just getting the color though. I'm not entirely sure how to apply the chosen color to pets.

Missy Master
08-27-2018, 10:13 AM
I might be able to work that out. :)

Thank you so much, I appreciate the tips!