Dynamically create a select element and add options to
Posted on 2005-03-03
I know how to dynamically add a select element to a form like so.
iteration = iteration + 1
var boldtype = document.createElement('Select');
boldtype.setAttribute('name', 'bold' + iteration);
But, I cant figure out how to add options to that select. I have tried to grab that select box like so.
boldopt = form.elements['bold'+iteration];
boldopt = new Option("NO', 'NO');
boldopt = new Option("YES', 'YES');
But I get an undefined on boldopt = form.elements['bold'+iteration].
Is there another way to be able to add options to this newly created select element?