E: quick js question about calling functions

  • From: Alex Hall <mehgcap@xxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sat, 18 Apr 2009 00:21:58 -0400

I would like to call the function when the enter key is pressed in an input box (input type="text"). I know about how to do it with buttons and links, but not with textboxes; it should not be a clickable object; I just want the user to be able to hit enter and have the function called. Thanks.


Have a great day,
Alex

----- Original Message -----
From: "Adrian Beech" <a.beech@xxxxxxxxxxxxxx
To: <programmingblind@xxxxxxxxxxxxx
Date sent: Sat, 18 Apr 2009 11:07:01 +1000
Subject: RE: quick js question about calling functions

G'day Alex,

Yup it certainly can be done. For clickable objects such as
buttons the tag
which I use goes along the lines of <input type="button"
value="Click Me"
onclick="myFunction()"/> and with hyperlinks I use <a
href="javascript:myFunction()">Click Me</a>. It's also generally
good
practice to put the functions in a separate .js file and add a
<script
type="text/javascript" src="my_functions.js"></script> within the
head
section of your page.

HTH.

Cheers.
AB


-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex
Hall
Sent: Friday, 17 April 2009 11:37 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: quick js question about calling functions

Hi all,
Just a quick question: in a webpage, I have a textbox.  I would
like the user to be able to hit the ENTER key in this box and
call a function, instead of needing to click a button.  The page
is a simple game meant to be played offline, so the page should
not go anywhere or reload itself.  Basically, I want the enter
key inside a textbox to take the place of a button.  Can this be
done?

Have a great day,
Alex
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind



__________ NOD32 4017 (20090417) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com


__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts:

  • » E: quick js question about calling functions - Alex Hall