Hola gente! como va?
Les comento, necesito mostrar en un form, a modo de rows, un dropdown, con datos desde una BD, un input tipo texto y otro dropdown mas... y con un boton [Agregar mas] necesito duplicar estos 3 elementos uno debajo del otro.
Buscando encontre este codigo que lo hace con inputs tipo texto, funciona perfectamente, pero no se cual es el codigo necesario para agregar Selects y las etiquetas Option para cada valor del 1er. y 3er. Dropdown:
Código HTML:
<script type="text/javascript">
var fieldCount = 1;
function mas() {
fieldCount++;
var newFriend = document.createElement('input');
newFriend.type = 'text';
newFriend.name = 'recibe' + fieldCount;
newFriend.id = 'recibe' + fieldCount;
document.getElementById('reco').appendChild(newFriend);
}
</script>
<style type="text/css">
input {
display: block;
margin-bottom: 2px;
}
button {
float: right;
}
fieldset {
border: 1px solid black;
}
</style>
<form>
<label for="envia">Tu Nombre</label>
<input type="text" name="envia" id="envia">
<fieldset id="reco">
<legend>Recomendar a </legend>
<button onclick="mas(); return false;">
Agregar otro
</button>
<input type="text" name="recibe1" id="recibe1">
</fieldset>
<input type="submit" value="Recomendar">
</form>
Eso es todo, gracias de antemano!