Change the background color by taking RGB values as input

<html>
<head>
<style type=”text/css”>
body
{
background-color:#B8BFD8;
}
</style>
<script type=”text/javascript”>
function changeStyle()
{

document.body.style.backgroundColor=”rgb(“+document.forms[0].c1.value+”,”+document.forms[0].c2.value+”,”+document.forms[0].c3.value+”)”;
}
</script>
</head>
<body>
<form name=”form1″>
<input type=”text” name=”c1″ value=”0″/>
<input type=”text” name=”c2″ value=”0″/>
<input type=”text” name=”c3″ value=”0″/>
<input type=”button” onclick=”changeStyle()” value=”Change background color” />
</form>
</body>
</html>

About vchaithanya

Software Engineer
This entry was posted in JavaScript. Bookmark the permalink.

Leave a comment