It seems like there's a problem with the code below that is causing it to not work as expected. I'm trying to figure out why the onclick events on the <option>
s are not triggering, but everything else seems fine.
function displayInput() {
document.getElementById('inputField').value = "";
document.getElementById('inputField').style.display = 'block';
document.getElementById('lineBreak').style.display = 'block';
}
function hideInput() {
document.getElementById('inputField').style.display = 'none';
document.getElementById('lineBreak').style.display = 'none';
}
#inputField {
display: none;
}
#lineBreak {
display: none;
}
<select name="" id="dropdown">
<option value="choose" onclick="hideInput();">Please choose</option>
<option value="Allure" onclick="hideInput();">Allure</option>
<option value="Elle" onclick="hideInput();">Elle</option>
<option value="In-Style" onclick="hideInput();">In-Style</option>
<option value="other" id="otherOption" onclick="displayInput();">Other</option>
</select>
<input type="text" name="additional_field" id="inputField" placeholder="Other" />
<br id="lineBreak" />