'Using user inputted email for JavaScript firebase

I am following this guide: https://www.firebase.com/docs/web/guide/login/password.html

They have hardcoded strings as the email and password.

How can I get the user to input there own values and submit it to the database?

 <form action="" onsubmit="createUser()">
      Email: <input type="text" name="email"><br>
      Password: <input type="password" name="password"><br>
      Repeat Password: <input type="password" name="password"><br>
      <input type="submit" value="Sign up" >
    </form>

I have this code above and would like to use this so that the user can enter whatever email they like and be registered. However, the docs only seem to cover hardcoded strings?



Solution 1:[1]

You can do it in a following way:

let email = document.getElementById("email")
let password = document.getElementById("password") 

Call firebase function

app.createUserWithEmailAndPassword(email, password).then((res:any)=> {

    // some code

}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sjaustirni