Luey
asked on
change div background onChange
This code I have works to change the background color.
However I would like to be able to use the option value
to change the color of the div. Is it possible to get my option value into
my javascript?
However I would like to be able to use the option value
to change the color of the div. Is it possible to get my option value into
my javascript?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
<!--
function colorBox()
{
window.document.getElementById("little_box").style.background = "#000";
}
-->
</script>
<style type="text/css">
<!--
#little_box {
background-color: #FFF;
height: 30px;
width: 30px;
border: thin solid #000000;
}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<label onchange="javascript:colorBox();">
<select name="color" id="color">
<option value="0033FF">blue</option>
<option value="FF0048">red</option>
<option value="EDFF00">yellow</option>
</select>
</label>
</form>
<div id="little_box"></div>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How about this?
document.getElementById("little_box").Style.backgroundColor = document.getElementById("form1").value;
ASKER
Perfecto Thanks good job
Open in new window