EchoAngel has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I created this internal website for my internal work group. I have a perl search. How can setup up the code such that when I enter "Enter Key", the search button on my page would execute automatically instead of me just telling everyone to keep clicking on the button ?

20050206 Edit by castaway: Changed title from 'Perl/CGI : Need to execute button when i enter "Enter" key'

  • Comment on (OT) Need to execute button when i enter "Enter" key

Replies are listed 'Best First'.
Re: (OT) Need to execute button when i enter "Enter" key
by BUU (Prior) on Feb 03, 2005 at 22:20 UTC
    By default 'enter' in a form element calls the submit action for that element. No set up required. Also nothing to do with perl.
      can you give me an example? I have multiple submit buttons...
        I have multiple submit buttons...

        Bad karma, but if you must (and yes, there can be a few valid reasons to do so)... make your desired default submit button the first in the form (test... different browsers may behave differently), and make the other buttons "buttons" instead of "submit". Then make those "button" buttons fire a JavaScript submit() with the appropriate action value in a hidden field.