Array will be declared as Array() not [] the append statment will be this output.innerHTML += numbers[x]+','; and to take value you should give numbers[0]=document.getElementById("1").value; not numbers[0]=document.getElementById("1");
I am not very good with the formatting !