I have an external Javascript file and I try to alert value of select tag.
My <select> code is as follows:
<select id="vote"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> <input type="button" value="vote" onclick="castvote();">
and Javascript (which is external):
function castvote() { alert(document.vote.options[document.vote.selectedIndex].value); }
But I get the error "document.vote is undefined".
Can someone help me with this.
Best zeeshan
javascript html
Zeeshan rang
source share