Enable / Disable input when clicking on a checkbox [closed]

2

I have this code:

function EnableDisableTextBox(quant_a0) {
  var txtquant_a0 = document.getElementById("quant_a0");
   txtquant_a0.disabled = quant_a0.checked ? false : true;
  if (!txtquant_a0.disabled) {
    txtquant_a0.focus();
  }
}
<div class="form-group col-md-4">
    <div class="p-3 mb-2 bg-secondary text-white">
      <p>Tamanho do Cartaz</p>
    </div>
    <div class="custom-control custom-checkbox col-md-5">
      <input type="checkbox" class="custom-control-input" name="tamanhoCartaz[]" value="0" id="customCheck1" onclick="EnableDisableTextBox()">
      <label class="custom-control-label" for="customCheck1">Cartaz A0</label>
      <input type="text" name="quant[]" class="form-control" placeholder="Quantidade" id="quant_a0" disabled>
    </div>
    <div class="custom-control custom-checkbox col-md-5">
      <input type="checkbox" class="custom-control-input" name="tamanhoCartaz[]" value="1" id="customCheck2" onclick="EnableDisableTextBox()">
      <label class="custom-control-label" for="customCheck2">Cartaz A1</label>
      <input type="text" name="quant[]" class="form-control" placeholder="Quantidade" id="quant_a1" disabled>
    </div>
    <div class="custom-control custom-checkbox col-md-5">
      <input type="checkbox" class="custom-control-input" name="tamanhoCartaz[]" value="2" id="customCheck3" onclick="EnableDisableTextBox()">
      <label class="custom-control-label" for="customCheck3">Cartaz A2</label>
      <input type="text" name="quant[]" class="form-control" placeholder="Quantidade"id="quant_a2" disabled>
    </div>
    <div class="custom-control custom-checkbox col-md-5">
      <input type="checkbox" class="custom-control-input" name="tamanhoCartaz[]" value="3" id="customCheck4" onclick="EnableDisableTextBox()">
      <label class="custom-control-label" for="customCheck4">Cartaz A3</label>
      <input type="text" name="quant[]" class="form-control" placeholder="Quantidade" id="quant_a3" disabled>
    </div>
    <div class="custom-control custom-checkbox col-md-5">
      <input type="checkbox" class="custom-control-input" name="tamanhoCartaz[]" value="4" id="customCheck5" onclick="EnableDisableTextBox()">
      <label class="custom-control-label" for="customCheck5">Cartaz A4</label>
      <input type="text" name="quant[]" class="form-control" placeholder="Quantidade" id="quant_a4" disabled>
    </div>
  </div>

The idea would be to enable / disable inputs [text] by clicking on the checkbox

    
asked by anonymous 21.11.2018 / 12:37

0 answers