javascript - Display text based on drop down selection (code works on jsfiddle but not website?) -
i having issues code somewhere can't figure out. here jsfiddle link
document.getelementbyid('email-list').onchange = function() { var = 1; var mydiv = document.getelementbyid(i); while(mydiv) { mydiv.style.display = 'none'; mydiv = document.getelementbyid(++i); } document.getelementbyid(this.value).style.display = 'block'; };
works fine on there can work on either of 2 different websites local on wamp or live. missing something?
your js fiddle example works because have selected onload
option in jsfiddle. make sure have wrapped code window.onload
window.onload = function(){ document.getelementbyid('email-list').onchange = function() { var = 1; var mydiv = document.getelementbyid(i); while(mydiv) { mydiv.style.display = 'none'; mydiv = document.getelementbyid(++i); } document.getelementbyid(this.value).style.display = 'block'; }};
Comments
Post a Comment