0

Right now i have a verifying code here:

<script type="text/javascript">
     var i = prompt("Enter The Password: ");
     if (i === x) {
         window.location.href = '';
     }
     else {
         document.write("PASSWORD INVALID!!!")
     }
</script>

and another piece of code is here:

<script> <!-- not the same as above -->
    var x = prompt("Choose a password: ");
</script>

I would like to take the value from the 'choose a password' prompt in the second script, in order to create a password on the 'enter the password' prompt. Bascially the x variable in the second script must be the same as x variable in the first script. Any suggestions?

Michael Chen
  • 37
  • 1
  • 8

1 Answers1

0

If I understand correctly. You can export the 'x' variable from file and import it in the file where you need it.

You can read about imports and exports on MDN (imports) or somewhere else, there is a lot of examples on this topic.

David Grabnar
  • 16
  • 1
  • 3