RE: [greenstone-users] Press Enter to start the query with mgpp

From Jonathan Tremblay
DateFri, 28 Apr 2006 17:05:35 -0400
Subject RE: [greenstone-users] Press Enter to start the query with mgpp
In-Reply-To (043E0C44967387478662B95CDAEBC0A72A9704CB-quebec-praxnet-local)

Hi Richard,


The script that you suggested worked with Internet Explorer, but not with FireFox… So I combined it with a script found on the web site you referred. Now it works with both navigators (but not with Netscape 4…). Here’s the recipe…


Add this to the _formpagescriptextra_ macro:

function entsub(event,ourform) {

  if (window.event && window.event.keyCode == 13)



    if (event && event.which == 13)



      return true;}


Add this to each input=”text” tag:

onkeypress="return entsub(event,this.form)"




Jonathan Tremblay

De : Richard Managh []
Envoyé : 27 avril 2006 00:27
À : Jonathan Tremblay
Cc : Greenstone
Objet : Re: [greenstone-users] Press Enter to start the query with mgpp


Hi Johnathan,

Probably the reason your searches arent initiating is that the mgpp search form "Begin Search" button, isnt a "submit" type form input control. Instead it uses an onclick property/event handler to call the javascript function beginSearch()  One "trick" you could use to start searches would be to capture when a user hits enter when the cursor is in any of the search input boxes.

add this javascript to the search page by modifying relevant macros:

function entsub(myform) {
  if (window.event && window.event.keyCode == 13){
  } else {
    return true;

add this code to the input type="text" tags of the search form by modifying relevant macros.

onkeypress="return entsub(this.form)"

I havent tested this method specifically, but used a variation on it a year or so ago for preventing the enter key submitting forms, so this or a slight variation on this should produce the desired effect.

My source for the idea is here:

hope this is helpful,


DL Consulting
Greenstone Digital Library and Digitisation Specialists

Jonathan Tremblay wrote:



In a collection built with mg, pressing Enter in a field of the search page starts the search. However, when using mgpp, it doesn’t work. I’ve looked at but did not understand the cause of this behavior.


What should I change to allow users to start queries with Enter?




Jonathan Tremblay


greenstone-users mailing list