OnSubmit på en form
Jeg har en login form hvor 3 felter skal submit´es videre til en anden siden for at kunne logge ind.Koden ser således ud:
<html style="background-color:transparent">
<head>
<title></title>
<script>
function redirecttologin()
{
var companyvalue ='nocompany';
var namevalue ='noname';
var passwordvalue = 'nopassword';
var companyinput = document.getElementById('company');
if (companyinput)
companyvalue = companyinput.value;
var nameinput = document.getElementById('username');
if (nameinput)
namevalue = nameinput.value;
var passwordinput = document.getElementById('password');
if (passwordinput)
passwordvalue = passwordinput.value;
var href = '' + location.href;
window.location.href = "http://www.x.dk/nav.aspx?action=loginiframe&company=" + companyvalue + "&name=" + namevalue + "&password=" + passwordvalue;
}
</script>
<style type="text/css">
TD {FONT-SIZE: 11px; FONT-FAMILY: Arial; COLOR: #4B4B4B}
.textfield {BORDER-RIGHT: #D5DEE9 1px solid; BORDER-TOP: #D5DEE9 1px solid; FONT-SIZE: 11px; BORDER-LEFT: #D5DEE9 1px solid; COLOR: #000000; BORDER-BOTTOM: #D5DEE9 1px solid; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif}
.button {BACKGROUND-IMAGE: url(http://www.x.dk/files/sysadmins/Grafik/login.gif); BORDER-BOTTOM: #30b457 0px solid; BORDER-LEFT: #30b457 0px solid; PADDING-BOTTOM: 1px; PADDING-LEFT: 0px; WIDTH: 40px; PADDING-RIGHT: 0px; FONT-FAMILY: Arial; FLOAT: none; HEIGHT: 17px; COLOR: #ffffff; FONT-SIZE: 11px; BORDER-TOP: #30b457 0px solid; BORDER-RIGHT: #30b457 0px solid; PADDING-TOP: 0px; cursor=pointer}
</style>
</head>
<body style="background-color:transparent">
<form name="form1" onsubmit="redirecttologin();">
<TABLE style="MARGIN-LEFT: -10 px; MARGIN-TOP: 10px" border=0 cellSpacing=0 cellPadding=0>
<tr>
<td width=110>Virksomhed</td>
<td width="8"> </td>
<td align="left" colspan="2"><input class="textfield" name="company" type="text" id="company" size="20" maxlength="20"></td>
</tr>
<tr>
<td width=110>Bruger</td>
<td width="8"> </td>
<td align="left" colspan="2"><input class="textfield" name="username" type="text" id="username" size="20" maxlength="20"></td>
</tr>
<tr>
<td width=110>Kodeord</td>
<td width="8"> </td>
<td align="left"><input class="textfield" name="password" type="password" id="password" size="12" maxlength="20">
<input class="button" type="submit" value="Login"></td>
</tr>
</table>
</form>
</body>
</html>
Jeg kan ikke få det til at virke med onSubmit i form tag´et.
Hvis jeg laver mit form tag således, så virker det fint:
<form name="form1">
<TABLE style="MARGIN-LEFT: -10 px; MARGIN-TOP: 10px" border=0 cellSpacing=0 cellPadding=0>
<tr>
<td width=110>Virksomhed</td>
<td width="8"> </td>
<td align="left" colspan="2"><input class="textfield" name="company" type="text" id="company" size="20" maxlength="20"></td>
</tr>
<tr>
<td width=110>Bruger</td>
<td width="8"> </td>
<td align="left" colspan="2"><input class="textfield" name="username" type="text" id="username" size="20" maxlength="20"></td>
</tr>
<tr>
<td width=110>Kodeord</td>
<td width="8"> </td>
<td align="left"><input class="textfield" name="password" type="password" id="password" size="12" maxlength="20"></td>
<td align="left" onclick="redirecttologin();" class="button"> Login</td>
</tr>
</table>
</form>
ulempen er så nu, at der bruges onclick og dvs. så kan jeg ikke bruge enter knappen for at logge ind, men udelukkende musen. Det er jo ikke så smart overfor brugeren.
Håber der er nogen der har en løsning. På forhånd tak.