JSFiddle - React, Tailwind, and code Playground
by Rapha Souza
HTML
<script src="//code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="form-group col-5">
<select name="itemSupCadastrado" id="itemSupCadastrado" class="form-control" onchange="campoBrancoSup();">
<option value="">Selecione*</option>
<option value="sim">Sim</option>
<option value="nao">Não</option>
</select>
</div>
<div class="form-group col-4" id="exibeAprovador">
<label>Campo 1</label>
<input type="text" id="itCodigo" class="form-control">
</div>
<script>
function campoBrancoSup(){
var opcaoItem = document.getElementById("itemSupCadastrado").value;
if (opcaoItem == "sim"){
document.getElementById("itCodigo").value = "CADASTRADO";
//document.getElementById('itCodigo').setAttribute('disabled', 'disabled');
document.getElementById('exibeAprovador').style.display = 'none';
}
if (opcaoItem != "sim"){
document.getElementById("itCodigo").value = "";
//document.getElementById('itCodigo').removeAttribute('disabled', 'disable');
document.getElementById('exibeAprovador').style.display = '';
}
}
</script>
JavaScript
function campoBrancoSup(){
var opcaoItem = document.getElementById("itemSupCadastrado").value;
if (opcaoItem == "sim"){
document.getElementById("itCodigo").value = "CADASTRADO";
}
if (opcaoItem != "sim"){
document.getElementById("itCodigo").value = "";
}
}