On the problem of variables

 var i=1;
      function changeColor(bg,num){
         
          box.style.color=bg;
          box.innerHTML=(iPP)*num;
          
          
       }        
         
      btn1.onclick=function(){
         
         changeColor("red",1);
       
       }
        
      btn2.onclick=function(){
          
         changeColor("green",2);
          
       }
         
      btn3.onclick=function(){
          
         changeColor("yellow",3);
          
       }//
       
Mar.04,2021

is not clear enough. If you want the global variable I to be 1 every time, just define it in the changeColor function.


var i=0, color = "";
function changeColor(bg,num){
    if(color !== bg) {
        i = 0;
        color = bg;
        box.style.color=bg;
    }//0
    box.innerHTML=(iPP)*num;
 }        
   
btn1.onclick=function(){
   
   changeColor("red",1);
 
 }
  
btn2.onclick=function(){
    
   changeColor("green",2);
    
 }
   
btn3.onclick=function(){
    
   changeColor("yellow",3);
    
 }//

reset when clicked

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b613-2c26f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b613-2c26f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?