- 4,029
- Derbyshire, UK
- DG Silva
Not so much of a 'what have you done' but 'what haven't you done'....
Can anyone see what is wrong with my HTML please? I can get it to work in JSFiddle, but load it into chrome straight from the file and it doesn't work. Basically, it's supposed to load up a set of links depending on which option you have chosen. I know there is an issue when it first loads, but no links come up whichever option you choose.
Can anyone see what is wrong with my HTML please? I can get it to work in JSFiddle, but load it into chrome straight from the file and it doesn't work. Basically, it's supposed to load up a set of links depending on which option you have chosen. I know there is an issue when it first loads, but no links come up whichever option you choose.
Code:
<HTML>
<head>
<script>
document.getElementById('options').onchange = function() {
var i = 1;
var myDiv = document.getElementById(i);
while(myDiv) {
myDiv.style.display = 'none';
myDiv = document.getElementById(++i);
}
document.getElementById(this.value).style.display = 'block';
};
</script>
</head>
<body>
<select name="options" id="options">
<option value="1">Useful links</option>
<option value="2">Order Support links</option>
<option value="3">Product links</option>
</select>
<br/><br/>
<div id="1" style="display: none">
<a href="http://hfd-wfm-int-web1/TeleoptiWFM/Web/MyTime#Schedule/Week" target="_blank">WFM</a>
<br/>
<a href="http://www.halfords.com" target="_blank">Halfords.com</a>
</div>
<div id="2" style="display: none">
<a href="http://www.dhl.co.uk/en/express/tracking.html" target="_blank">DHL Tracking</a></div>
<div id="3" style="display: none">
<a href="http://i1.adis.ws/i/washford/616353" target="_blank">Product picture</a></div>
</body>
</HTML>