I\'m trying to change the background image of the body (id = \"shelf\") using a drop-down menu:
It's working.
function changeTheme() {
var e = document.getElementById("themes");
var theme = e.options[e.selectedIndex].value;
document.getElementById("shelf").style.backgroundImage = "url(" + theme + ")";
}
What exactly is the behavior you are seeing?
Try this:
<html>
<head>
<script type="text/javascript">
function changeTheme()
{
var e = document.getElementById("themes");
var theme = e.options[e.selectedIndex].value;
console.log(theme);
document.getElementById("shelf").style.backgroundImage = "url("+theme+")";
}
</script>
</head>
<body id="shelf">
<select id="themes" onChange="changeTheme()">
<option value="images/bg/default.png">Default</option>
<option value="images/bg/oriental.png">Oriental</option>
<option value="images/bg/office.png">Office</option>
<option value="images/bg/old.png">Old</option>
</select>
</body>
</html>