2
I have this checkbox:
<select id="valores_confinamento" class ="form-control">
<option value="ceu" >Ceu aberto</option>
<option value="galpao" selected>Galpão fechado</option>
</select>
And I would like that when selected it was possible to change the value in:
<div style="top: 95%; left: 34%;position: absolute">
<span id="id_area_piquete_por_animais" ></span>
</div>
I did:
var selection = document.getElementById("valores_confinamento");
var selected = selection.options[selection.selectedIndex].text;
function valor(){
if (selected =="ceu" ){
document.getElementById("id_area_piquete_por_animais").innerHTML=10;
}
if (selected =="galpao" ){
document.getElementById("id_area_piquete_por_animais").innerHTML=20;
}
}
valor();
selection.addEventListener("keyup",valor);
selected .addEventListener("keyup",valor);
But it doesn’t return something.
Thank you Renan, just what I wanted!
– Carlos Andre
marquei, thank you very much!
– Carlos Andre