Need my <input type=text> to fire a JavaScript on "enter"

H

Hoss

Hi guys,

The framework of my page is an aspx page with a header and a footer.
The header is a menu system and depending on what you select there
different ascx pages are loaded into the middle part. So the entire
page is encased in <form> tags. For this reason I cannot create <form>
tags on a given ascx page. It screws things up. So, on one of my
controls, I have the following

-- set of 6 <input type=text id="myId">
-- <input type=button value="Search" onclick="SearchDocuments()">

Wehn you click the button it fires the script and does its thing. I
also want that if you hit enter
while you are in one of the text fields, it will fire the same script.
Remember you cant encase
the 7 elements into a <form>

Thanks-
 
V

VK

Hoss said:
Hi guys,

The framework of my page is an aspx page with a header and a footer.
The header is a menu system and depending on what you select there
different ascx pages are loaded into the middle part. So the entire
page is encased in <form> tags. For this reason I cannot create <form>
tags on a given ascx page. It screws things up. So, on one of my
controls, I have the following

-- set of 6 <input type=text id="myId">
-- <input type=button value="Search" onclick="SearchDocuments()">

Wehn you click the button it fires the script and does its thing. I
also want that if you hit enter
while you are in one of the text fields, it will fire the same script.
Remember you cant encase
the 7 elements into a <form>

<input type="text" name="myName" onkeydown="
var key = event.which || event.keyCode;
if (key == 13) {// ? I guess for Enter - you better check
SearchDocuments();
return false;
}
">
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top