Reputation: 41
I am kind of newbie with JavaScript and web application programming. I am trying to create an "Auto Login" utility that will fill the UserName/PWD fields and will auto submit the information to server and will login to the application without user intervention. This is same as another utility available called "RoboForm". Due to some privacy issues I can't use this RoboForm or any third party utility for this purpose in my current organisation. So, I decided to create it on my own.
This is what I am trying to do; Once I am on the login page of my application, I am writing below javascript code in the browser's address bar:
javascript:document.getElementById('Username').value='xyz';document.getElementById('Password').value='xyz_123';document.getElementById('Destination').value='TestDB';document.forms['Form1'].submit();
With this code everything is working fine except, form is not getting "Auto Submitted". I have to manually click on "Login" button to proceed further.
I did some research on google and got to know that the button id should not be "Submit". I verified that and the application I am trying to login has some diffrent id so that is not the problem. I am not sure why the form is not getting "Auto Submitted".
Please note that the application I am trying to login to is a third party application and I do not have access to the source code.
Can anyone please help me with this? If any other alternatives are there to achieve the same, please suggest me.
Thanks! Swad
Upvotes: 0
Views: 158
Reputation: 41
I found out the solution:
Instead of document.forms['Form1'].submit();
use document.getElementById('cmdLogin1').click();
Upvotes: 0
Reputation: 499
If your form name is Form1
then the code for auto submit should be
document.forms[0].submit();
or
document.Form1.submit();
Upvotes: 0