Quantcast
Channel: Programming – Programming blog – website programming blog, blog on website programming .net, java , php and mor
Viewing all articles
Browse latest Browse all 31

Change Your Page Background Color Dynamically using Java Script

$
0
0
Following code is used to change a page color from your select option in select box.

Copy and Paste following code in a simple HTML page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Change Your page Background Color Using Java Script</title>
		<script type="text/javascript">
			function changeTheme(selColor) {
				alert(selColor);
				document.body.style.backgroundColor = selColor;
			}
		</script>
	
	</head>
	<body>
	<h1>Please Select Your Page Background Color..</h1>
		<select name="changescheme" id="changescheme" onChange="javascript:changeTheme(this.value)">
			<option value="white">White</option>
			<option value="red">Red</option>
			<option value="blue">Blue</option>
			<option value="orange">Orange</option>
			<option value="black">Black</option>
		</select>
	</body>
</html>

Viewing all articles
Browse latest Browse all 31

Trending Articles