I’ve created a form that posts to a cfm file. When running a script onLoad that fills in the form values and tries to submit…The site takes me back to the login screen.
<script>
function f()
{
document.getElementById("email").value = "asdf@asdf.com";
document.getElementById("password").value = "asdf";
document.getElementById("form1").submit();
}
</script>
Please help!
update:
Here is the code….When the values for email and password are filled ini manually and the enter button is pressed it will direct me to the home page. However, when writing a script that submits the form onload, it redirects me to the login page.
<form action="https://www.asdf.com/dev/mem/login/login.cfm" method="post" id="caring" name="login" style="margin: 0px; padding: 0px;">
<input name="page" type="hidden" id="page" value="https://www.asdf.com/dev/mem/home/home.cfm">
<table>
<tr>
<td rowspan="2" class="title"></td>
<td class="label"><label for="email"></label></td>
<td class="element"><input name="email" id="email" value ="asdf@asdf.com" /></td>
<script>
//<td rowspan="2" class="action"><input type="submit" name="login" value="submit" alt="go" title="go" /></td>
</script>
</tr>
<tr>
<td class="label"><label for="username"></label></td>
<td class="element"><input name="password" value = "asdf" id="password" /></td>
</tr>
<td rowspan="2" class="action"><input type="submit" name="login" value="enter" alt="go" title="go" /></td>
<tr>
<td></td>
<td colspan="2"> </td>
<td> </td>
</tr>
</table>
</form>
It’s hard to tell without the HTML of the form itself, but my guess would be that the
action=""attribute of your form is blank. If that attribute is blank, the browser will post the form back to the same page.Since you’re using coldfusion, check to see if there is code generating your
action=""value, and look for bugs in it if so. It may help to view the rendered HTML source of the page.