Ir para conteúdo
Fórum Script Brasil

phillypmack

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre phillypmack

phillypmack's Achievements

0

Reputação

  1. Boa tarde! preciso que após o enter ser pressionado a seleção pule para a próxima caixa, e depois se o enter for pressionado de novo o formulario seja enviado, esse é o meu código: <!DOCTYPE html> <html> <head> <!--Import Google Icon Font--> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!-- Compiled and minified CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"> <!--Let browser know website is optimized for mobile--> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> </head> <body> <div class="container"> <div class="row"> <div class="input-field col s12"> <i class="material-icons prefix">edit</i> <input id="OS" type="text" class="validate"> <label for="OS">ORDEM DE SERVIÇO</label> </div> <div class="input-field col s12"> <i class="material-icons prefix">dock</i> <input id="EQUIP" type="text" class="validate"> <label for="EQUIP">ID MAQUINA</label> </div> <div class="input-field col s12"> <button class="btn waves-effect waves-light" id="btn">ENVIAR <i class="material-icons right">send</i> </button> </div> </div> </div> <!-- Compiled and minified JavaScript --> <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script> <script> var ordemBox = document.getElementById("OS"); var maquinaBox = document.getElementById("EQUIP"); document.getElementById("btn").addEventListener("click",addRecord); function addRecord(){ var ordem = ordemBox.value; var maquina = maquinaBox.value; if(ordem.trim().length == 0 || maquina.trim().length == 0){ M.toast({html: 'INSIRA A ORDEM DE SERVIÇO E ATIVO!'}) //google.script.run.errorMessage(); --- error example ---- }else{ var data = { ordem: ordemBox.value, maquina: maquinaBox.value }; google.script.run.appendData(data); ordemBox.value = ""; maquinaBox.value = ""; }//CLOSE ELSE }//CLOSE ADD RECORD </script> </body> </html> e esse é a condição que não consegui mesclar ao meu código. // Get the input field var input = document.getElementById("myInput"); // Execute a function when the user releases a key on the keyboard input.addEventListener("keyup", function(event) { // Number 13 is the "Enter" key on the keyboard if (event.keyCode === 13) { // Cancel the default action, if needed event.preventDefault(); // Trigger the button element with a click document.getElementById("myBtn").click(); } });
×
×
  • Criar Novo...