function rellenaSelect2Input(idSelect,idInput){ var campoSelect = document.getElementById(idSelect); var campoInput = document.getElementById(idInput); var valor = campoSelect.options[campoSelect.selectedIndex].innerHTML; campoInput.value=valor; } function rellenaSelect2InputLoc(idSelect,idInput,idSelect2){ var campoSelect = document.getElementById(idSelect); var campoInput = document.getElementById(idInput); var campoSelect2 = document.getElementById(idSelect2); var valor = campoSelect.options[campoSelect.selectedIndex].innerHTML; campoInput.value=valor; // Averiguamos el optgroup var optgroup=campoSelect.options[campoSelect.selectedIndex].parentNode.label; for(i=0;i