I will assume that when you say two forms, username and password you mean two text inputs, and then submit the form.
What you should do, is:
- Select each text input and change its
value
attribute. - Submit the form
Could be done with the following code, assuming that your form has an id="my-form"
, your username input has id="username"
and your password input has id="password"
.
document.getElementById("username").value = "myusername"; // Select and fill username input
document.getElementById("password").value = "mypassword"; // Select and fill password input
document.getElementById("my-form").submit(); // Submit the form