Ok so im new to JavaScript and programing in general so i got this kind of assignment that isnt hard but i still cant manage to figure it out...I need to make combo box in form,and create a div outside that form.Then i need JS function that will show what have i choosed from combo box into that div...
<script>
function omiljeniFilm(){
var lista=document.getElementById("lista");
var ispis=lista.options[lista.selectedIndex].text;
document.getElementById("omiljeni").value=ispis;
}
</script>
<body>
<form>
Izaberi omiljeni film:
<select id="lista" onchange="omiljeniFilm();">
<option>Gospodar prstenova</option>
<option>Hari Poter</option>
<option>Pobesneli Maks</option>
<option>Titanik</option>
</select>
</form>
<div id="omiljeni">
</div>
</body>
I used the same function that i write before for very similar assignment that adds choosen words to forms input element but it doesnt work with this div outside the form...
You need two changes
the function would be:
function omiljeniFilm(){
var lista=document.getElementById("lista");
document.getElementById("omiljeni").innerText=lista.value;
}