-2
I have this button to enter a new record:
<button type="button" name="add6" id="add6" class="btn btn-primary disable" data-toggle="modal" data-target="#exampleModal6" data-whatever="@getbootstrap" style="font-size: 12px;">Passagem de Turno</button>
And this button to update to another page but using the same form as the previous button:
<button type="button" name="edit6" data-toggle="modal" href="#exampleModal6" id="'.$row6["Id6"].'" class="btn btn-primary edit_data6 disable1" >Editar</button>
the input textarea dque exist within the form:
<div class="form-group">
  <h6><label for="Observacao-name" class="col-form-label">Tarefa Pendente</label></h6>
  <textarea type="text" id="Observacao6" name="Observacao6" class="form-control"></textarea>
</div>
<div class="disabled form-group">
 <h6><label for="Observacao-name" class="col-form-label">Conclusão</label></h6>
 <textarea type="text" id="Conclusao" name="Conclusao" class="form-control"></textarea>
</div>
javascript to the first button:
$(".disable").click(function (){
        // desabilitando o campo 
    $('#Conclusao').attr("disabled", true);
    // mudando a cor do campo
    $('#Conclusao').css("background-color", "#cccccc"); 
}); 
and on the second button page I also put to the other textarea:
$(".disable1").click(function (){
  // desabilitando o campo 
  $('#Observacao6').attr("disabled", true);
  // mudando a cor do campo
   $('#Observacao6').css("background-color", "#cccccc"); 
});
When I insert it works correctly as shown in the image:
But when I update it blocks both textarea, but I should only block the first:
I call the page (which is select16), why the conexao16 only has the php for insert and make update where you have the edit button and trigger disable1 as follows:
$(".disable").click(function (){
        // desabilitando o campo 
    $('#Conclusao').attr("disabled", true);
    // mudando a cor do campo
    $('#Conclusao').css("background-color", "#cccccc"); 
});
$('#add6').click(function(){  
           $('#insert6').val("Gravar");  
           $('#insert_form6')[0].reset();  
      });
    $('#insert_form6').on("submit", function(event){  
           event.preventDefault(); 
           if($('#Colaborador6').val() == "")  
           {  
                alert("Colaborador é necessário");  
           }               
           else  
           {  
                $.ajax({  
                     url:".conexao26",  
                     method:"POST",  
                     data:$('#insert_form6').serialize()
                     ,  
                     beforeSend:function(){  
                          $('#insert6').val("Inserting");  
                     },
                     success:function(data){                     
                          $('#insert_form6')[0].reset();  
                          $('#exampleModal6').modal('hide'); 
                          $('#employee_table6').html(data);                       
                          location.reload("exampleModal6");                       
                     }  
                });  
           }  
      });
       $(document).on('click', '.view_data6', function(){  
           var employee_id6 = $(this).attr("Id");  
           if(employee_id6 != '')  
           {  
                $.ajax({  
                     url:"./select16",  
                     method:"POST",  
                     data:{employee_id6:employee_id6},  
                     success:function(data){  
                          $('#employee_detail6').html(data);  
                          $('#dataModal6').modal('show');  
                     }  
                });  
           }            
      });     
But the problem only arises if you use both buttons, use only the edit button already works correctly, but using both no longer works.
html:
<form method="post" id="insert_form6">
        <div class="col-md-4 col-xs-4">
          <div class="form-group">
            <h6><label for="Data-name" class="col-form-label">Data</label></h6>
            <h6><input type="date" name="data6" id="data6" value="<?php echo date("Y-m-d");?>"></h6>
          </div>
          </div>
          <div class="col-md-4 col-xs-4">
          <div class="form-group">
            <h6><label for="Colaborador-text" class="col-form-label">Colaborador</label></h6>
            <h6><select style="width:150px" name="Colaborador6" id="Colaborador6" required>
<option></option>
<?php
$sql = "SELECT Funcionario FROM centrodb.InfoLuvas WHERE Ativo = '1' AND Funcao = 'Limpeza' AND Valencia = 'LAR'";
$qr = mysqli_query($conn, $sql);
while($ln = mysqli_fetch_assoc($qr)){
  echo '<option value="'.$ln['Funcionario'].'">'.$ln['Funcionario'].'</option>';
}
?>
</select></h6>
</div>
</div>
<div class="row">
         </div>
          <div class="col-md-6 col-xs-6">
          <div class="form-group">
            <h6><label for="Observacao-name" class="col-form-label">Tarefa Pendente</label></h6>
            <textarea type="text" id="Observacao6" name="Observacao6" class="form-control"></textarea>
          </div>
          </div>
          <div class="col-md-6 col-xs-6">
          <div class="form-group">
          <h6><label for="Observacao-name" class="col-form-label">Estado</label></h6> 
          <div style="clear:both;"></div>
          <h6><input type="radio" id="Estado" name="Estado" value="Pendente"> Pendente     <input type="radio" id="Estado" name="Estado" value="Concluído"> Concluído</h6> 
          </div>
          </div>
          <div class="row">
         </div>
          <div class="col-md-6 col-xs-6">
            <div class="disabled form-group">
            <h6><label for="Observacao-name" class="col-form-label">Conclusão</label></h6>
            <textarea type="text" id="Conclusao" name="Conclusao" class="form-control"></textarea>
          </div>
          </div>
          <div class="col-md-2 col-xs-2">
          <div class="form-group">
          <h6><input type="hidden" name="Nome6" id="Nome6" value="Ana Ribeiro" readonly="true"></h6>
          </div>
          </div>
          <div class="col-md-2 col-xs-2">
          <div class="form-group">
          <h6><input type="hidden" name="NomeConc" id="NomeConc" value="Ana Ribeiro" readonly="true"></h6>
          </div>
          </div>
          <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Sair</button>
        <input type="hidden" name="employee_id6" id="employee_id6" />
        <input type="submit" name="insert6" id="insert6" value="Registo" data-toggle="modal" class="btn btn-success" /> 
      </div>
        </form>


You put the trigger on the same button:
$(".disable").click(function (){. The edit button is classy.disable1. Would that be?!– LipESprY
Can you better explain how the file structure is? Your answer depends a little on where you are calling each javascript function. For example: you could show that such a page containing X content calls such a file containing Y content. Maybe Lipespry answered!!
– Cedric S.
@Lipespry the problem is not that, even fixing this problem happens the same.
– Bruno
I confess that I’m having a little trouble understanding your codes. Maybe it’s the "before lunch" syndrome. Consider making the details easier and I’ll be back after lunch to try to help you! ;D
– LipESprY
@Cedric S. edited the question with the
ajaxthat calls the page that has the triggerdisable1– Bruno
you only put a few snippets of the code
html, And in these parts do not appear the buttons mentioned. However a test you can do and swap your selectors for something a little more specific like$('button.disable').click(...)and$('button.disable1').click(...)I say this because you can this using this class.disablein other elements.– Icaro Martins
@Icaro Martins did the test as indicated above but the result is the same, when I click on the edit button are both blocked
– Bruno
Look at this example the button
<button type="button" name="add6" id="add6" class="btn btn-primary disable" ....>is receiving 2 events fromclickthat$(".disable").click(...)and that$('#add6').click(...), it is worth checking if this is correct and if this repeats with other events. If you add thehtmlof your code may be easier for the community to identify the problem - [mcve]. = D– Icaro Martins
@Icaro Martins added html to the question
– Bruno