I'm trying to change dynamically the text of a span based on the the option that got selected. PS: I'm using Django + Python to generate options
Here is my code :
<select class="form-control" id="materials">
{% for material2 in materials %}
<option value="{{ material2.name }}">{{ material2.name }}</option>
{% endfor %}
</select>
<span id="material_display></span>
I've tried :
var selected_material = document.getElementById("materials").value;
document.getElementById("material_display").innerTEXT = selected_material
But that didn't work out.
innerText, you have a case difference. Also are you doing this logic as part of a change event handler or something?