Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142239

Use variable in other .js file

$
0
0

I'm working on a normal login, but how can I use a variable also in an other file in Vanilla JS?

I've tried to use a return but that didn't worked...

I would really apprechiate it if someone helps me out.

My code:

let alertText, alertBox, attempt, allowed;
attempt = 3;
allowed = false;

goBack = () => {
    window.history.back();
}

logIn = () => {
 let allowed = false;
 let username = document.getElementById('user').value;
 let password = document.getElementById('ww').value;

 if(username === 'test12345'&& password === 'test12345') {
     window.location.href = 'admin.html';
     allowed = true;
 } else {
     alertText = 'Inlogegevens ongeldig';
     alertBox = document.getElementById('error').style.display = 'block';
     alertBox = document.getElementById('error').innerHTML = alertText;
     attempt--;

     if(attempt === 0) {
         document.getElementById('user').disabled = true;
         document.getElementById('ww').disabled = true;
         document.getElementById('submit').disabled = true;

         alertBox = document.getElementById('error').innerHTML = 'Gegevens vergeten?!??'
     }
     allowed = false;
 }
}

Viewing all articles
Browse latest Browse all 142239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>