Fake submit button & return

I

Ike

I'm hoping someone can tell me how to do something which, though trivial to
some, I'm really struggling with here. If I have an href, which, through the
magic of CSS, we make appear as a button (a surrogate Submit button no
less), I somehow need to make it pick up when "enter" ("return") is pressed,
so that it acts like a real Submit button. In other words, I think somehow
the href needs to pick up the focus, and if it HAS the focus, will it then
act the same as if it were clicked upon? Below is the construction of the
button, without the css:

<div class="rvbuttons" style="padding-right:81px;" >
<a href="javascript:document.frmLogin.submit();" align="left"
class="rvbutton" style="float:center;" onClick="return
chkLogin()">Submit</a>
</div>

TIA, Ike
 
D

David Dorward

Ike said:
I'm hoping someone can tell me how to do something which, though trivial to
some, I'm really struggling with here. If I have an href, which, through the
magic of CSS, we make appear as a button (a surrogate Submit button no
less), I somehow need to make it pick up when "enter" ("return") is pressed,
so that it acts like a real Submit button.

So you want something that looks like a submit button and acts like a
submit button - so why don't you use a submit button instead of messing
around with JavaScript / CSS dependant modification of something
designed to do something entirely different?
 
S

subp

If I understand you right, you want your submit function to be
triggered by pressing the enter key on the keyboard, right?

Adding javascript to the page like this might be what you need:

function fetchKey() {
if (window.event.keyCode == 13) {
// submit code in here
}
}

document.onkeydown=fetchKey;

So, when a key is entered, it checks to see if it's the enter key (13)
and if it is, it does your submit. I'm also curious why you wouldn't
just use a real submit button. If it has to be a get instead of a
post, then just add the method="get" attribute to your form. Just
guessing that that might be one reason why you would want a link
instead of a button.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top