Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Post login data to site with js

I would like to write a small script that upon running it should fill some data in a html site that are already given. So for example lets say the site is the stackoverflow logn page and I need to fill my username and password.

Knowing that for the username we have:

<input type="email" name="email" id="email" size="30" maxlength="100" placeholder="[email protected]">

password:

<input type="password" name="password" id="password" placeholder="********">

and data:

data = {username:"user", password:"pass"};

our js should be something like below (correct?):

document.getElementById("email").value=data.username; 
document.getElementById("password").value=data.password; 

What I dont really understand is how to "post" that into the site and then hit the login button.(ajax?) Generally how to bring it together and make it a running script.

Thanks in advance.

like image 828
John James Avatar asked Sep 01 '17 14:09

John James


1 Answers

document.getElementById("myForm").submit();

having embedded you input filed in an HTML form with id="myForm"

like image 156
GavinBrelstaff Avatar answered Oct 22 '22 20:10

GavinBrelstaff