views:

111

answers:

1

Hi, I have a classic asp page with two buttons, one for LOGON and another for REGISTER. I have named both buttons as "bsubmit" so I can query the value to determine which button is pressed. That works fine.. But when the user presses ENTER, I want the LOGON button to trigger instead of the REGISTER button.

This page has a hidden input tag also with a name ='action'. It seems when pressing ENTER, the first button on the page is activated (which is REGISTER). How can I fix this to trigger LOGON on ENTER?

The hidden and two button definitions follow:

response.write "<input type='hidden' name='action' value='" & dictEnvironment("V-ACTION") & "'>" & CRLF

response.write "<input class='bbsbutton margintop12px' type='submit' name='bsubmit' value='Guest Register'><br/>" & CRLF

response.write "<input class='bbsbutton' type='submit' name='bsubmit' value='Forum Logon'>&nbsp;<br/>" & CRLF

Thank you, James

A: 

Option 1 (no Javascript)

Change the first input to button, and leave only one submit

response.write "<a href='register.asp'>button class='bbsbutton margintop12px' name='bsubmit'>Guest Register</button></a><br/>" 

response.write "<input class='bbsbutton' type='submit' name='bsubmit' value='Forum Logon'>&nbsp;<br/>" 

Option 2 (Javascript)

Use a small javascript to detect the enter and act accordingly

<SCRIPT TYPE="text/javascript">
<!--
function onFormSubmit(e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   myform.submit();
   return false;
   }
else
   return true;
}
//-->
</SCRIPT>
Eduardo Molteni
Very nice! Thanks
James
But how do I supply the (e) to the onFormSubmit function?
James
`<form onkeydown="onFormSubmit(event);">`
Eduardo Molteni