im trying to copy the existing options from a select to another one after a DOMContentLoaded event and im having some strange behavior as a result:
<select id='select'>
<option id='1'>option 1</option>
<option id='2'>option 2</option>
<option id='3'>option 3</option>
<option id='4'>option 4</option>
</select>
<P>New option:</P>
<input type="text" name='new'>
<input type="button" value="crear" onclick='create()'></button>
<p>Edit</p>
<div id='editElement'>
<select name="selectEdit" id="selectEdit"></select>
<input type="text" id='edit'>
<input type="button" value="edit" >
<input type="button" value="remove" >
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
select = document.getElementById('select');
selectEdit = document.getElementById('selectEdit');
for (let index = 0; index < select.length; index++) {
selectEdit[index] = select[index];
}
} );
</script>
some of the existing options from the 1st select are missing and in the second that im filling is incomplete too...i broke js?