Ok so I have a code that would show different forms based on dropdown selection
Here\'s the fiddle to that..
Well its always giving me Test1 which means its not cha
That is because in the fiddle your code is set to run at onLoad, but in your code its running before the DOM is created.
Wrap your code into a window.onload event like this:
window.onload = function()
{
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';
};
};
Anyway, like @positivew remembered, your code misses the tag. Is semantically correct to put your JS scripts inside it.