Home > Domino Tips > Developer > JavaScript > Using the Enter key to click a button in Lotus Notes
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

JAVASCRIPT

Using the Enter key to click a button in Lotus Notes


Peter Smith
07.11.2006
Rating: -3.12- (out of 5)


Lotus Notes and Domino tips, tutorials and how-to articles
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


VIEW MEMBER FEEDACK TO THIS TIP

Rather than using a mouse to click a button, or tabbing to the button and hitting the space bar, you can make Lotus Notes more like the Web by just hitting "Enter" to click the button. This is useful in things like search forms.

All client JavaScript events

YourSearchField onFocus
useClick = window.setInterval("runSearch()",100);
OR
Form onLoad
useClick = window.setInterval("runSearch()",100); 

YourSearchField onBlur
window.clearInterval(useClick);

YourSearchButton
The button has an HTML Name/ID of Search

Form JS Header
var newline = String.fromCharCode(10);
var useClick;
var sString;
var t_sString;

function runSearch() {
  sString = document.forms[0].Query.value;
   if (sString.indexOf(newline)>=0)    {
      t_sString = replace(sString, '\n', '');
      document.forms[0].Query.value = t_sString;
      document.forms[0].elements['Search'].click();
    }
}

function replace(str, from, to) {
           var i = str.indexOf(from);
           if (!from || !str || i == -1) return str;
           var newstr = str.substring(0, i) + to;
           if (i+from.length < str.length)
           newstr += replace(str.substring
(i+from.length,str.length),from,to);
           return newstr;
}

MEMBER FEEDBACK TO THIS TIP

This tip is exactly what I was looking for, but it doesn't seem to work for me. Is there any way you can help me?
—Serge M.

******************************************

I just tested this by copying and pasting the code into a form and it worked fine, so I think it's one of the following issues:

  1. The user is using an old copy -- e.g., before you amended it. They should use what is currently there, specifically, check the line: t_sString = replace(sString, '\n', '')

  2. They don't have JavaScript enabled in their Lotus Notes client, or have an earlier release. It wasn't tested on R5.

  3. They haven't replaced the relevant parts of the code. For example, the field in the example is called "Query," whereas their search field might be called something different. Likewise, the HTML name for the button in the example is called "Search." Theirs may be named something different or not named at all.

—Peter Smith, tip author

******************************************

The tip was amended on June 18, 2006. It is reflected in the code above.
—Matt Gervais, SearchDomino.com Assistant Editor

******************************************

This is a nice tip, but it is important to mention that the rich-text field used as a search query must have: "enable multiple lines" on the control tab. If it is not, there won'tbe newlines characters in the field, and the JavaScript won't fire.
—Gregory E.

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Peter Smith Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
JavaScript for Lotus Notes Domino
Trap JavaScript runtime errors in Domino Web apps
JavaScript workaround fixes Lotus Notes 8.x PostOpen event issue
Write HTML and JavaScript in Notes view rows and columns on the Web
JavaScript detects Web browser type and version in Notes/Domino 8.0.2
JavaScript creates a jump box on a Lotus Notes Web form
Top 10 Lotus Notes/Domino coding and development tips of 2008
How to create dynamic JavaScript in Notes Domino without formulas
Trap an attachment path via the Domino file upload control field
Converting Lotus Notes views to XML documents using JavaScript
Mimic Lotus Notes Domino application functionality on the Web

JavaScript
Trap JavaScript runtime errors in Domino Web apps
JavaScript workaround fixes Lotus Notes 8.x PostOpen event issue
Write HTML and JavaScript in Notes view rows and columns on the Web
JavaScript detects Web browser type and version in Notes/Domino 8.0.2
JavaScript creates a jump box on a Lotus Notes Web form
How to create dynamic JavaScript in Notes Domino without formulas
Trap an attachment path via the Domino file upload control field
Converting Lotus Notes views to XML documents using JavaScript
Prevent errors on iFramed pages with JavaScript
How to add keyboard functionality for Lotus Notes documents

IBM Lotus Messaging and Collaboration Clients
Daylight Saving Time 2007 -- seven helpful tips for Lotus Notes administrators
IBM will add social networking tools for business
Lotusphere 2007 refocuses on users
Top 10 Notes/Domino administration tips of 2006
Advice sought re lack of Notes/Outlook interoperability
IBM grabs lead in Unix server revenue
Add server connection documents while installing Notes
As laptop use rises, so do doctor visits
Ambuj Goyal on Workplace, .NET opportunity for IBM (Parts 1 and 2)
Amid IBM's bad revenue news, Lotus Software up 11% in Q1

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts