0
I’m trying to use the function onchange
, I can even pick up the value, but I can’t make use of the value obtained, Follow the code:
function myFunction() {
var x = document.getElementById("mySelect").value;
document.getElementById("demo").innerHTML = x;
}
<div>
<select id="mySelect" onchange="myFunction()">
<option value="1">1 Questão
<option value="2">2 Questões
<option value="3">3 Questões
<option value="4">4 Questões
</select>
</div>
<b id="demo"></b> <!--aqui eu imprimo o valor de x corretamente-->
I would like to use the value of X
as a complement to the image address
tried so:
<img src="img/gab<?echo '<b id="demo"></b>'?>.png" />
Thus
<img src="img/gab<script>x</script>.png" />
and
<img src="img/gab<script>$x</script>.png" />
I don’t know how to do