I keep getting the error "Uncaught TypeError: Cannot read property 'add' of null"
, which happens on the line select.add("HI!", 0);
. I thought it was because of a name mismatch, which is why the list exists, but that did not solve the problem. Any guidance would be awesome!
<script type="text/javascript">
for(i = 0; i < 10; i++){
var names = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
//window.alert(names[i])
document.write('<tr>');
document.write('<td>');
document.write('<select id=names[i]></select>');
var select = document.getElementById(names[i]);
select.add("HI!", 0);
document.write('</td>');
document.write('</tr>');
}
</script>
Thank you