Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEED HELP....Using Enter key with Links

Status
Not open for further replies.

SmileyFace

Programmer
Sep 10, 2002
99
US
On a screen if I have some images with links, is there a way of moving to the next screen by just hitting the enter key....basically assigning one of the images to the 'Enter' key so that the user doesn't have to go from keyboard to mouse just for that screen? The screen IS NOT a form.

Thanks a lot for any help!
 
keyboard to mouse....why?

[Hammer]
Nike Failed Slogans -- "Just Don't Do It!"
 
You mean like paging through a photo album or some such by pressing the enter key no?

[tt]<script>
//Put the 'next page' location into a variable:
var nextPage = '
//Define a function to move to the next page
function moveNext(){
window.location.href = nextPagel
}


//Define a function to examine keypress events
function examineKeyPress(){
if(window.event.keyCode==13){
moveNext();
}
}

</script>
[/tt]


Trap the keypress event by ensuring the examineKeyPress function runs when the user presses a key:
[tt]<body onkeypress=&quot;examineKeyPress&quot;>[/tt]

And that should do the trick.
 
Hey Dwarfthrower! This sounds about right as far as what I want to do but theres just one problem. The next page is not an html page its an asp page which links like this <a href=&quot;CallInfo_Step1.asp?CustomerID=<%=rs(&quot;ci_cust_id&quot;)%>&quot;

Basically have to pass on an ID to the next page. How can this be done inside of the script? Thanks again for your help.

 
You can embed VBScript within Javascript... like:

<script type=&quot;text/javascript&quot; language=&quot;javascript&quot;>
//Put the 'next page' location into a variable:
var nextPage = [red]'CallInfo_Step1.asp?CustomerID=<%=rs(&quot;ci_cust_id&quot;)%>'[/red];

//Define a function to move to the next page
function moveNext(){
window.location.href = nextPage
}


//Define a function to examine keypress events
function examineKeyPress(){
if(window.event.keyCode==13){
moveNext();
}
}
</script>
 
Hey cool! Thanks Mr3Putt and Dwarfthrower. It worked!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top