Disable Combo select

0

Expensive;

I tried in several ways to disable the combo Select (mespgto) when checkBox (radio04) is checked "checked == true", but with no success. Could you help me?

Note: In the form that the function is (release), it only comes to lock the combo select, and is not the expected behavior.

Here's some code snippet:

     <script>

     function liberar() {

    if  (document.getElementById('radios03').checked==true)
    {
    document.getElementById('parcela').disabled=false
    }



    if  ( document.getElementById('radios04').checked==true)
    {
          document.getElementById('parcela').disabled=true

          document.getElementById('parcela').value=""

          document.getElementById('mespgto).disabled=true
    }

   }

    </script>



    <div class="form-group">
  <label class="col-md-4 control-label" for="textinput">Parcelado: </label>  

  <div class="col-md-4">
  <div class="radio" onchange="liberar();">
    <label for="radios-0">
      <input type="radio" name="radio" id="radios03" value="Sim" >
      Sim
    </label>
    </div>
  <div class="radio" onchange="liberar();">
    <label for="radios-1">
      <input type="radio" name="radio" id="radios04" value="Nao" checked="checked">
      Não

    </label>
    <p>
    </div>

 <label><input  type="text" disabled id="parcela" onkeyup="somenteNumeros(this);" name="parcela" maxlength="2"  style="width:50px;"  class="form-control input-md">
 Máximo 12 parcelas
  </label>
  <p id="saida"></p>
    </div>
</div>

<form name="mespgto" >
<div class="form-group">
  <label class="col-md-4 control-label" for="radios">Meio de Parcelamento:</label>

  <div class="col-md-4">
  <select class="mespgto" id="mespgto" name="financeiro" >
  <option  disabled selected>Selecione</option>
  <option value="xxx" id="xxx"   >xxx</option>
  <option value="yyy" id="yyy"  >yyy</option>
  <option value="www" id="www"  >Santander www</option>
  <option value="outros" id="outros"   >Outro</option>

  </select>
</div>
</div>
</form>'
    
asked by anonymous 31.01.2017 / 16:20

2 answers

0

You're missing a ' in line document.getElementById('mespgto).disabled=true example in fiddle

function liberar() {

  if (document.getElementById('radios03').checked == true) {
    document.getElementById('parcela').disabled = false
  }

  if (document.getElementById('radios04').checked == true) {
    document.getElementById('parcela').disabled = true
    document.getElementById('parcela').value = "";
    document.getElementById('mespgto').disabled=true
    }
  }
    
31.01.2017 / 16:26
0
    <div class="form-group">
      <label class="col-md-4 control-label" for="textinput">Parcelado: </label>  

      <div class="col-md-4">
      <div class="radio" onchange="liberar();">
        <label for="radios-0">
          <input type="radio" name="radio" id="radios03" value="Sim" >
          Sim
        </label>
        </div>
      <div class="radio" onchange="liberar();">
        <label for="radios-1">
          <input type="radio" name="radio" id="radios04" value="Nao" checked="checked">
          Não

        </label>
        <p>
        </div>

     <label><input  type="number" disabled id="parcela"  name="parcela" maxlength="2"  style="width:50px;"  class="form-control input-md">
     Máximo 12 parcelas
      </label>
      <p id="saida"></p>
        </div>
    </div>

    <form name="mespgto" >
    <div class="form-group">
      <label class="col-md-4 control-label" for="radios">Meio de Parcelamento:</label>

      <div class="col-md-4">
      <select class="mespgto" id="mespgto" name="financeiro" >
      <option  disabled selected>Selecione</option>
      <option value="xxx" id="xxx"   >xxx</option>
      <option value="yyy" id="yyy"  >yyy</option>
      <option value="www" id="www"  >Santander www</option>
      <option value="outros" id="outros"   >Outro</option>

      </select>
    </div>
    </div>
    </form>'


         <script>

         function liberar() {

            document.getElementById('parcela').disabled=true
            if  (document.getElementById('radios03').checked==true)
            {
                document.getElementById('parcela').disabled=false
            }


            document.getElementById('parcela').disabled=false

            document.getElementById('parcela').value=""

            document.getElementById('mespgto').disabled=false

            if  ( document.getElementById('radios04').checked==true)
            {
                  document.getElementById('parcela').disabled=true

                  document.getElementById('parcela').value=""

                  document.getElementById('mespgto').disabled=true
            }

           }

        </script>
    
31.01.2017 / 17:21