Link to home
Start Free TrialLog in
Avatar of garethtnash
garethtnashFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Javascript - Auto Submit Form

I have a senario, where my client operates on many platforms, all that require their users to login and in most cases with different credentials for each platform.

I have suggested a master slave relationship, whereby the master site maintains a database that stores all other platform login details.

So upon logging into the master site, the user can easily login to any of the slave sites, without needing to enter additional login details.

The login details for each slave site would be stored in a database record.

However having looked at some of the existing platforms, they all use the "post" methods for the login form, so I was planning on therefor submittin g the form via javascript...

(I've tried the code below, but it doesn't work) Is this because the target (action) is on another domain / server, or is there something wrong with the javascript?

Many thanks

<body onload="submitForm()">
<form method="post" action="http://www.slavedomain.co.uk/index.php" name="myForm" id="myForm">
<input type="hidden" name="username" value="candidate" />
<input type="hidden" name="passwd" value="candidate" />
</form>
<!-- now send the form! -->
<script type='text/javascript'>document.myForm.submit();</script>
</body>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sjklein42
sjklein42
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of garethtnash

ASKER

Spot on - thank you, I missed some variables :)
Thank you