For some reason, I cannot get this to work. I am new to JS (and pretty new to coding in general) and I've been looking at it for several hours and searching here as well. I do not see what is wrong with my code.
I am trying to retrieve a value from a select options list. I want to use that value in another function.
This is what I am trying, and "Vocation" does not change to the value, even though I believe it should.
<body>
<div class="wooh" style="width:200px;margin: 25px;">
<select id="Vocation">
<option value="0">Select Voc:</option>
<option value="3.0">EK</option>
<option value="1.4">RP</option>
<option value="1.1">ED</option>
<option value="1.1">MS</option>
</select>
<p id="result">Vocation</p>
</div>
<script>
// Edit your script here
function selection() {
var x = document.getElementById("Vocation").value;
document.getElementById("result").innerHTML = x;
}
</script>
My end "goal" is to pass the value on to this function:
var x = document.getElementById("level").value;
var y = [value here]
var z = 1600
var a = 305000
document.getElementById("result").innerHTML = Math.ceil((z * Math.pow(y, x))/305000);
Where y should be the value from the selected option. What am I doing wrong?