JSFiddle - React, Tailwind, and code Playground

by Swapnil Khamkar

HTML

<form name="frmNameAge" id="frmNameAge" method="get" action="">

<table id="formTable">

<tr>
    <td>Name:</td>
    <td><input type="text" max="50" name="txtName" id="name" />

    </td>
</tr>

<tr>
    <td>Age:</td>
    <td><input type="text" max="10" name="txtAge" id="age" /></td>
    <tr>
    <td colspan="2"><hr></td>
</tr>

<tr>
    <td align="center" colspan="2"><input type="button" name="btnSubmit"    value="Submit" id="button"></td>
</tr>

</table>

</form>

JavaScript

document.getElementById("button").onclick = function () {
var strColor = prompt("Enter your favorite color.");
if ( strColor != null) {
	changeBackgroundColor(strColor)
}

}

function changeBackgroundColor(strColor) {
document.body.style.background = strColor;
}