0
In the code below is caught the option value
selected and used as link (href)
, but I need it to be used as onClick
:
<form action="" method="POST" role="form">
<li>
<select id="bens" name="bens" class="form-control"
onChange="alterarComboVeiculo(this.value); ">
<option value='' selected>Selecione</option>
<option value='86764554'>867</option>
<option value='88564554'>885</option>
</optgroup>
</select>
</li>
</form>
<span id="alex">Selecione</span><a onclick="" href="" id="url"></a>
here where you are href=""
the empty space is replaced by the option value
selected
<script type="text/javascript">
var select = document.getElementById('bens'),
output = document.getElementById('alex');
select.addEventListener('change', function() {
output.textContent = '' ;
var index = this.selectedIndex;
var prefix = "";
var suffix = "";
prefix = 'addOverlay_' + select.options[select.selectedIndex].text + "();";
var link = document.getElementById("url");
link.href = prefix;
link.innerHTML = "Alex";
});
</script>
You couldn’t do it
link.addEventListener("click", prefix)
?– Woss