Jump to content
Fórum Script Brasil
  • 0

PRÓXIMA CAIXA E ENVIO DE FORMULÁRIO COM (ENTER)


Question

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();
  }
});

 

Edited by phillypmack
Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Cloud Computing


  • Forum Statistics

    • Total Topics
      148691
    • Total Posts
      644530
×
×
  • Create New...