RNG to a hidden input and post it

  forms, hidden, input, javascript, random

I want to generate a random number and post it to php.

<form method="post" name="login_post_form">
  <label for="username">Username  :</label>
  <input type="text" name="username" id="username" />
  <label for="password">Password :</label>
  <input type="password" name="password" id="password" />
  <input type="hidden" name="randomNumberGen" id="randomNumberGen" value="" />
  <script>
    var randomNumber = Math.floor(Math.random() * 1000);
    document.getElementById('randomNumberGen').value = randomNumber;
  </script>
  <input type="submit" name="submit" value="Login" />
</form>

It does’nt post any data, like it doesn’t generate any number .

my sources is in the img:
enter image description here

Source: Ask Javascript Questions

LEAVE A COMMENT