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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event key and Imagebuttons problems

Status
Not open for further replies.

lunargirrl

Programmer
Jan 26, 2004
77
BR
Hi all :)

I am using a javascript that makes keypress event. when i use the code in an <asp:button...> it works fine, when i try after enter to focus on a <asp:imagebutton...>, it shows me the following error: 'document.form1.btnLocalizar' is null or not an object.

my code is bellow:

the script
----------

<SCRIPT LANGUAGE="JavaScript">
nextfield = "txtCPF"; // first field of my form
netscape = "";
ver = navigator.appVersion; len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");
function keyDown(DnEvents) {
k = (netscape) ? DnEvents.which : window.event.keyCode;
if (k == 13) {
if (nextfield == 'done') {
} else {
eval('document.Form1.' + nextfield + '.focus()');
return false;
}
}
}
document.onkeydown = keyDown;
if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);
</SCRIPT>

after the form tag
--------------------

<asp:textbox id="txtCPF" tabIndex="1"
runat="server" onfocus="nextfield='btnLocalizar';"></asp:textbox>



<asp:imagebutton name = "btnLocalizar" id="btnLocalizar" ImageUrl="..\Images\btn_mag.gif" tabIndex="2"></asp:imagebutton>

I want when press enter on txtCPF it focuses on btnLocalizar.


Glad someone could help me

venusgirrl

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top