Values are only strings or integers and a seperator(',') should not present in an array.
document.getElementById("hiddenfield").value = oldArray.join(",");
To retreive that array back
NewArray = document.getElementById("hiddenfield").value.split(",");