Estoy realizando un sistema de pedidos donde las cajas de texto se tienen que estar creando dinamicamente pero mi problema es que no se como crear el select con sus opciones correspondientes.
tengo esto que me crea varios elementos y un select pero no se como agregar las opciones:
Código Javascript:
Ver original
num=0; function crear(obj) { num++; fi = document.getElementById('fiel'); contenedor = document.createElement('div'); contenedor.id = 'div'+num; fi.appendChild(contenedor); ele = document.createElement('select'); ele.name = 'unidad'+num; ele.options contenedor.appendChild(ele); ele = document.createElement('input'); ele.type = 'text'; ele.name = 'cantidad'+num; contenedor.appendChild(ele); ele = document.createElement('input'); ele.type = 'text'; ele.name = 'precio'+num; contenedor.appendChild(ele); ele = document.createElement('input'); ele.type = 'button'; ele.value = 'Borrar'; ele.name = 'div'+num; ele.onclick = function () {borrar(this.name)} contenedor.appendChild(ele); } function borrar(obj) { fi = document.getElementById('fiel'); fi.removeChild(document.getElementById(obj)); }
Espero me puedan apoyar. De antemano muchas gracias