I have the following select html:
<select id="remFieldset0Field5inputSelect" class="form-select">
<option value="1">Book 1</option>
<option value="2">Book 2</option>
<option value="3">Book 3</option>
<option value="4">Book 4</option>
<option value="5">Book 5</option>
</select>
I need to store the selected value on a variable as I'll use it to look for it on a json dictionary to alter other input values on the form (price, for instance), everything on the change.
I'm trying with this javascript code:
var bookSelectedValue = bookSelect.value
bookSelect.addEventListener('change', function() {
bookSelectedValue = bookSelect.value;
});
console.log(bookSelectedValue);
But value never changes. Any clues of what I'm doing wrong?
Thanks!