lunargirrl
Programmer
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
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