<input type="text" id="myInp"/> <script> function myFunction(){ return Math.floor(Math.random() * 100); } document.getElementById("myInp").value = myFunction(); </script>