开发者

How to trigger logon button when user presses enter on classic asp page with two buttons?

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开发者_JAVA百科;<br/>" & CRLF

Thank you, James


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜