0

I have some code using A login form and I need to reference a javascript variable inside a div. Here is the HTML.

    <div class="div"
    variable="Variable Here?" 
    </div>

Here is the javascript.

function setLoginFormVars(form) {
        localStorage.setItem('email', email = document.getElementById("email").value);
        localStorage.setItem('apikey', apikey = document.getElementById("apikey").value);
        window.location.href = 'miner.html';
      }

The javascript is in the file where the form is. The function setLoginFormVars Is run when the login button is clicked.

How would I specify that it is a variable and is it even possible to do what im asking.

Thank you.

Nyle

4
  • you should share the login JavaScript so that we can get a better understanding. Typically you would separate the JavaScript from the HTML for something like this. More than likely you wouldnt want inline JavaScript with your HTML. Commented Jul 17, 2018 at 15:50
  • added the javascript. Commented Jul 17, 2018 at 15:54
  • 'I need to reference a javascript variable inside a div' why would you have a javascript variable declared inside of an HTML div? can this variable be maintained within the javascript file? Commented Jul 17, 2018 at 15:58
  • Its to do with the coin-hive miner API. I am making a miner people can use. the reason I want to do this is because the miner requires the API key directly in the div. Commented Jul 17, 2018 at 16:05

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.