Forum Moderators: open

Message Too Old, No Replies

Issues with JS on IE and FireFox

         

rodentcentre

3:56 pm on May 8, 2005 (gmt 0)

10+ Year Member



Hi all, great forum this is...I'm relatively new to the client side scripting world and have a question about how IEv6.1 and FireFox treat form.submit()...following is an excerpt from my login page:

<form name="login" action="loginproc.php" method="POST">
<table>
<tr>
<td>Username:</td>
<td>
<input type="text" name="uname" id="uname" maxlength="10" size="10" />
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input type="password" name="pass" id="pass" maxlength="10" size="10" />
</td>
</tr>
<tr>
<td>
<a href="javascript: void(0);" onclick="login.submit();">Login</a>
</td>
<td>
<a href="javascript: void(0);" onclick="document.location = 'register.php'">Register</a>
</td>
</tr>
<tr>
<td>
<input type=submit value=GO>
</td>

</tr>

</table>
</form>


It works just fine in FireFox but when I try to click either link in IE nothing happens, it doesn't throw an error or anything, it just sits there. Any ideas on why this might be? Thanks a lot.

Bernard Marx

11:31 am on May 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1) onclick="login.submit();"

document.getElementsByName('login')[0].submit()
// or the old way:
document.forms.login.submit()

2) onclick="document.location = 'register.php'";

document.location is deprecated.

onclick="window.location.href = 'register.php';"

-----

It may also be better to cancel the default link action in both cases. eg:

onclick="window.location.href = 'register.php';return false;"

rodentcentre

8:08 pm on May 9, 2005 (gmt 0)

10+ Year Member



Right on! Thanks for that help, I really appreciate it.