Pages

Subscribe:

How To Change Webpage Background Color Using Javascript

This JavaScript program use switch case and radio button for change webpage background color.When you on-click radio button then radio button pass the value to JavaScript function . Switch case compare the value with the case which value is similar to the case ,then change webpage background color .

Program :  

<html><head></head>
<body>

<script language="JavaScript">
function colors(col)
{
switch(col)
{
case 'red':
document.bgColor="#FF0000";
break;
case 'green':
document.bgColor="#00FF00";
break;
case 'blue':
document.bgColor="#0000FF";
break;
}
}
</script>
<form name=”form1” method=”post” action=””>
<p>
<label>
<input type="radio" name=”Colors” value=”radio” onClick="colors('red')">
Red</label>
<br>
<label>
<input type="radio" name=”Colors” value=”radio” onClick="colors('green')">
Green</label>
<br>
<label>
<input type="radio" name=”Colors” value=”radio” onClick="colors('blue')">
Blue</label>
<br>
</p>
</form>
</body></html>

Output :


comments powered by Disqus
 

Listed In

Bloggers - Meet Millions of Bloggers http://Link-exchange.comxa.com
Blog Search: The Source for Blogs Internet Blogs

Disclaimer

The contents in this blog are taken from various sources available over the internet, therefore we do not gurantee of it's accuracy, if you find any of the content in the blog is infringing it's copyright, please do email us on '123techguide@gmail.com' and we will make sure to remove the same from the blog at the earliest.