473,388 Members | 1,277 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Problem when using two <h:commandButton>

58
Hi all,
I am working a page that consists two <h:commandButtons> n two
<h:inputText> fields,if i hit enter key the first button is invoked by default even when i am in second text field.I tried the following client side javascript inorder to invoke second command button from second text field,But its not working properly(Not working in mozilla too).

The code i tried was
----------------------------
Expand|Select|Wrap|Line Numbers
  1. function trapEnter(evt) {
  2.     var keycode;
  3.  
  4.     if (evt)
  5.         ;
  6.     else if (window.event)
  7.         evt = window.event;
  8.     else if (event)
  9.         evt = event;
  10.     else
  11.         return true;
  12.  
  13.     if (evt.charCode)
  14.         keycode = evt.charCode;
  15.     else if (evt.keyCode)
  16.         keycode = evt.keyCode;
  17.     else if (evt.which)
  18.         keycode = evt.which;
  19.     else
  20.         keycode = 0;
  21.  
  22.     if (keycode == 13) {
  23.         document.getElementById('formId:Button2').click();
  24.         return false;
  25.     }
  26.     else
  27.         return true;
  28. }
  29.  
  30.  
  31.  
  32.  
can any one give me a solution for this issue???

Thanks in Advance,
sundar....
Aug 29 '07 #1
2 1550
JosAH
11,448 Expert 8TB
That is a Javascript question posted in a Java forum; I'll move your question over
to a Javascript forum.

kind regards,

Jos
Aug 29 '07 #2
acoder
16,027 Expert Mod 8TB
Show the generated code for the command buttons and text fields in HTML, not JSP. View source on the browser.
Aug 29 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Filips Benoit | last post by:
Dear All, Form.source and report.source is the same table. Form has serveral comboboxes hiding the Foreign keys. Commandbutton in form to print the formselection using Form.filter as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.