Skip to content
Advertisement

Display the Color in a box for input RGB values in html/php

The code given below will give the Hex value after submission , but i also require a square box and a corresponding color filled in the box. want to get the red, green and blue value and want to display the color of that RGB value in a square box .

JavaScript
JavaScript

The objective is to get something like this, we will get input from user in Red, Green and Blue and will display that color in a square box as shown below.

enter image description here

Advertisement

Answer

Minimized the rgb2hex function and added a div with required style instead of input[type=color]

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement