Techiio-author
Started by Dixon MurrayNov 5, 2021

Open
how to stop script when user click on the button and once data capture then enable button

0 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWES SHARE

I've created an app script form for shooting interest for users.

So I want help at the beneath mentioned state of affairs.

When the person clicks on the login button then the script runs and different buttons are disabled till the first script effectively captures the statistics. Once the login button records are captured at the database then he can click on different buttons. Please assist me with this.

Edit the question to include the desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 mins ago.
(Private feedback for you)
function clockInOut(payload){
  
      console.log(payload)
      const ss =SpreadsheetApp.getActiveSpreadsheet()
      const wsData = ss.getSheetByName("Run")
      const now = new Date();
      const d= wsData.getDataRange().getDisplayValues().reverse();
      const emp_i = d.findIndex(r=> r[1]== payload.empid && r[2] !== payload.action && r[0] === payload.vcode);
      if(emp_i !==-1){
      Logger.log(emp_i)
      wsData.getRange(d.length-emp_i,6).setValue(now);
      }
      const a= wsData.getDataRange().getDisplayValues().reverse();
      const emp_c = a.findIndex(r=> r[1]== payload.empid && r[2] == payload.action && r[0] === payload.vcode );
      Logger.log(a)
      Logger.log(emp_c)
      if(emp_c !==-1 && a[emp_c][5] ==""){
        throw new Error("error")
      }
       wsData.appendRow([payload.vcode,payload.empid,payload.action,payload.work,now])
}
   ClockInOutApp.clockInOut = function(e){
              const payload = {
                                  empid :ClockInOutApp.empidInput.value,
                                  vcode :ClockInOutApp.vcodeInput.value,
                                  work  :ClockInOutApp.workInput.value,
                                  action : e.target.dataset.action
                              }

<form id="main-form">
<div class="form-inline">
   <div class="w3-row w3-padding">
     <div class="col">
         
            <label for="employee" class="text-bold fg-white">Logged in as</label>
            <select class="input-group-text bg-white" class="w3-select w3-yellow"  id="employee">
                
                <? for(let i=[0];i<emp.length;i++){ ?>
                <option>
                    <?= emp[i]; ?>
                </option>
                <? }?>
            </select>
        </div>
        </div>
        
        
        <div class="form-inline">
        <div class="w3-row w3-padding w3-cell">
            <div class="w3-full w3-padding">
              
        <button id="clock-in" class="w3-button w3-red" type="submit" data-action = "Login" onclick="
    Metro.activity.open({autoHide: 10000})" >LogIn</button>
        <button id="clock-out" class="w3-button w3-black" type="submit"data-action = "LogOut"onclick="
    Metro.activity.open({autoHide: 10000})
" >LogOut</button>
            </div>
             </div>
              </div>
      <div class="form-inline">
        <div class="w3-row w3-padding w3-cell">
            <div class="w3-full w3-padding" class="col-auto">
              
       
        <button id="clock-breakf"  class="button success" type="submit"data-action = "Short Break" class="button info" onclick="
    Metro.activity.open({type: 'bars',autoHide: 6000})">Short Break</button>
        <button id="clock-break" class="button success" type="submit"data-action = "Lunch/Dinner Break"class="button info"          onclick="
    Metro.activity.open({type: 'bars',autoHide: 6000})" >Lunch/Dinner</button>
     <script>       
 
           google.script.run.withSuccessHandler(() =>{
              ClockInOutApp.message.classList.remove("d-none")
             setTimeout(() =>  {ClockInOutApp.message.classList.add("d-none")},5000)  
           }).withFailureHandler(()=>{
              ClockInOutApp.mess.classList.remove("d-none")
             setTimeout(() =>  {ClockInOutApp.mess.classList.add("d-none")},5000)  
           }).clockInOut(payload)
             
             
           
          }
          
          
           
           
  
 
       document.addEventListener("DOMContentLoaded",ClockInOutApp.onload) 
</script>

0 Replies

You must be Logged in to reply
Trending Technologies
15
Software40
DevOps46
Frontend Development24
Backend Development20
Server Administration17
Linux Administration26
Data Center24
Sentry24
Terraform23
Ansible83
Docker70
Penetration Testing16
Kubernetes21
NGINX20
JenkinsX17
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance