Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: monitor onclick for checkboxes


Message #1 by speedguru@m... on Thu, 9 May 2002 11:23:33
yes.

create onclick event for whole window.
and then inside this function write next:

var curObj = event.srcElement;
if (curObj.tagName == "INPUT")
	if (curObj.type = "CHECKBOX")
		{
			//	Do whatever you need to do
		}

You also can create more conditions, for ecxample if you have particular
name
or some other property.

Oleg.

-----Original Message-----
From: speedguru@m... [mailto:speedguru@m...]
Sent: May 09, 2002 7:24 AM
To: javascript
Subject: [javascript] monitor onclick for checkboxes


i have got an asp page with N (N > 100) number of checkboxes and there is an
onclick event for each which execute a function.

<input type=checkbox onclick="run(this)">
<input type=checkbox onclick="run(this)">
<input type=checkbox onclick="run(this)">
.......
......

when the asp page is called, the html that is generated has the onclick
hardcoded for each checkbox.  just to reduce the amount of html code that is
finally generated , i was wondering if there is a way of monitoring using an
event handler if ANY checkbox has been clicked and then executing the
function for THAT particular checkbox..

something of this sort....

if event=onclick && elementtype='checkbox'
//identify id of checkbox and call function
run(id)

thanks for your time....




---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20


  Return to Index