HTML:
<div class="form-group">
<input class="input-sol form-control" id="focusedInput appendedInput sol" placeholder="Enter number" type="text" required>
<button class="btn btn-warning btn-large" id="submit" type="button" onClick="getUserChoice()">Get Images</button>
</div>
JavaScript:
function getUserChoice() {
var user_sol = document.getElementById("sol").value;
...
When I enter a value and click the button, my function is triggered but in console I get the following error:
Uncaught TypeError: Cannot read property 'value' of null
at getUserChoice (index.js:44)
at HTMLButtonElement.onclick (index.html:53)
The other values selected from a drop-down list are fine but not for this input.
focusedInput appendedInput sol?idisn't"sol"(and is, in fact, invalid). You may be confusing theidattribute with theclassattribute, which can have multiple values separated by spaces. w3.org/TR/html5/dom.html#element-attrdef-global-id