<input class="pm" name="electroone" type="hidden" value= ""> <script> var ar = ["1","3","4"] document.querySelector(".pm").value = ar[Math.random()*ar.length|0] </script>