i suggest a other way : might be more convenient
in my case i input a color and alpha and save them in a json file to call whenever the page is loaded it reads the json file for saved settings
the edit form to change the settings split up the saved color+alpha using substr()
then convert to dec with hexdec()
before form (php) :
$value = JData['Page];
$galHighlightColor = substr($value['galHighlightColor'], 0, 7);
$galBorderColor = substr($value['galBorderColor'], 0, 7);
$Ha = hexdec(substr($value['galHighlightColor'], 7, 2));
$Ba = hexdec(substr($value['galBorderColor'], 7,2));
then in the form use 'range' or 'number'(just do for each)(php):
echo "
<td class=\" w3-col s3\" >
<input type=\"color\" name=\"galBorderColor\" value= \"".$galBorderColor."\" ></input>
</td>
<td class \"tooltip\">
Alpha<input type=\"range\" value = \"$Ba\" step = \"1\" class = \"coordsInput\" id = \"Ba\" name=\"Ba\" placeholder = \"alha\" size=\"3\" maxlength = \"3\" min=\"0\" max=\"255\"></input>
<span class=\"tooltiptext tt-right\"> Apha 0-255 for this color </span>
</td>
";
handle the form save the complete 8 digit color code do for each get the color and convert the dec to hex again but using dechex()
now you got a color +alpha you can use in my example i save it in a json file (php):
<?php
if($_POST['Ba'] < 16){$R = '0'.dechex($_POST['Ba']);}else {$R = dechex($_POST['Ba']);} // edit: added this to handle missing leading 0
$JData['Page']['galBorderColor'] = $_POST['galBorderColor'].$R) ;
?>
Json file entry: "galHighlightColor":"#e63333c0","galBorderColor":"#d6a8a8ff"
use into html (php):
<?php
$galHighlightColor = $value['galHighlightColor'];
$galborderColor = $value['galBorderColor'];
echo"
<div style=\"background-color:$galHighlightColor; border-color: $galborderColor;\">
</div>
";
?>
'font' color, background-color, border-color.
background-color:rgba(192,192,192,0.3);
- that is rgba - w3schools.com/csSref/css_colors_legal.asp – Idiopathyrgba
– Frizzy