I am creating a website where I want users to be able to change the color of one of the divs. The color is set using rgba because I want it to be transparent.
The problem I am facing is that I found a color picker, but I change the RGB without pressing opacity. Here's how I have it so far:
<input class="color" type="text" onchange="document.getElementById('main-info').style.backgroundColor = '#' + this.color;">
Obviously, I am replacing rgba with hex, for a live version that kills opacity. Other things I've tried:
<input class="color" type="text" onchange=" document.getElementById('id_info_box_bg_color').value = (Math.floor(this.color.rgb[0]*255)) + ', ' + (Math.floor(this.color.rgb[1]*255)) + ', ' + (Math.floor(this.color.rgb[2]*255));">
which successfully gets rgba values, but I can't get it to correctly insert into rgba.
Does anyone know how I can replace the rgba part? So I just change Xs to rgba (X, X, X, .5)
source
share