airArray = ["CO_current_value", "22898", "CO_max_value", "39617.0", "CO_min_value", "0.0", "NO_current_value", "30", "NO_max_value", "262.0", "NO_min_value", "0.0", "O3_current_value", "102408", "O3_max_value", "798225.0", "O3_min_value", "5995.0", "RH_current_value", "68", "RH_max_value", "99.0", "RH_min_value", "20.0", "T_current_value", "23", "T_max_value", "42.0", "T_min_value", "1.0"]; airCount = airArray.length; for(x=0; x != airCount; x++){ air_ele = document.getElementById(airArray[x]); if(air_ele){ // check the named element exists in the page ! air_ele.innerHTML = airArray[x+1]; } x++; }