JSFiddle - React, Tailwind, and code Playground
HTML
<div class="formarea">
<select id="dropdown1">
<option value="One">"One"</option>
<option value="Two">"Two"</option>
<option value="Three">or just write your own</option>
</select>
<form><input id="txtbox" type="text"></input></form>
<input id="inputbutton" type="submit" value="Submit"></input>
</div>
CSS
.formarea{
height:300px;
width:300px;
margin:0 auto;
text-align:center;
padding:40px;
}
#txtbox{
margin-top:40px;
margin-bottom:40px;
width:200px;
}
JavaScript
var txt = document.getElementById('txtbox');
var btn = document.getElementById('inputbutton');
txt.disabled=true;
$(document).ready(function() {
$('#dropdown1').change(function() {
if($(this).val() == "Three"){
document.getElementById('txtbox').disabled=false;
}
else{
document.getElementById('txtbox').disabled=true;
}
});
});
btn.onclick = function () {
if((txt).disabled){
alert('input is: ' + $('#dropdown1').val());
}
else{
alert('input is: ' + $(txt).val());
}
};