How to Change the Background Color to the Value in a Text Box in HTML
- 1). Open a text editor such as Notepad, for example, or an HTML editor.
- 2). Locate the HTML tag of the text input field that you want to edit. A text input tag starts with "<INPUT" and contains a 'type="text"' attribute.
- 3). Insert the following attribute inside the input tag:
STYLE="background-color: X;"
Replace "X" in the code above with either the name of a common color, such as "red" or "black," or with the hexadecimal code of the Web color you wish to use. Your resulting input tag should look like this example, which you can use to create a red background:
<INPUT type="text" STYLE="background-color: red;"> - 4). Save your HTML file and upload it to your server, using an FTP program or your Web host's file manager tool.
Source...