473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

onClick for table a row, but not to its links!

Hi,

I have table with many rows indicating my record. I want my rows to
load my record, so I attached an onClick event to every row that loads
the proper record. Now, there are options associated to every record
(delete link, select checkbox, etc) that don't result in loading the
record. The problem should be obvious, upon the user clicking on any of
those options, the row's onclick is triggered which is undesirable
behaviour.

Any ideas how I would address this problem,

Regards,
Sia

Mar 13 '06 #1
3 3699
Siah said on 2006-Mar-13:
Hi,

I have table with many rows indicating my record. I want my rows to
load my record, so I attached an onClick event to every row that loads
the proper record. Now, there are options associated to every record
(delete link, select checkbox, etc) that don't result in loading the
record. The problem should be obvious, upon the user clicking on any of
those options, the row's onclick is triggered which is undesirable
behaviour.

Any ideas how I would address this problem,


I suppose you have onclick events on both the table cells and the rows.
In that case, you need to stop clicks on the cells from bubbling up to
the rows.

Read about events:

<URL:http://www.quirksmode.org/js/introevents.html>
There is quite a bit to read, but it is all good and very necessary to
understand what it going on. You are looking for stopPropagation and
cancelBubble (you need to do both or bubbling will still happen in some
browsers) which is in the section on event order:

<URL:http://www.quirksmode.org/js/events_order.html>
But note that if you cancel bubbling for click events on the cells, how
will anything bubble up to the row? :-)
--
Rob
Mar 13 '06 #2

Siah wrote:
Hi,

I have table with many rows indicating my record. I want my rows to
load my record, so I attached an onClick event to every row that loads
the proper record. Now, there are options associated to every record
(delete link, select checkbox, etc) that don't result in loading the
record. The problem should be obvious, upon the user clicking on any of
those options, the row's onclick is triggered which is undesirable
behaviour.

Any ideas how I would address this problem,

Regards,
Sia


Greetings,

One solution I have used for this problem is to place an image (Down
Arrow) inside a division at the right of each row. That image has the
onClick function. That function also changes the inner HTML of the
division to swap the Down Arrow image with an Up Arrow and also changes
the onClick function that is called.

This keeps the records from acting as elements of the row that wraps
them.

I can give you some code samples if you need. But this works really
well for me plus it gives your users a visual indication that the row
is expandable.

Hope this helps,
- Peter Schmalfeldt

Mar 13 '06 #3
Thanks for the help. I'll try it out before asking for sample code. I
think I can do it.

Thanks,
Sia

Mar 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the...
3
by: Jamie Jackson | last post by:
I'm rewriting all links' onclick events, but I'm having a problem. The onclick event that I'm inserting works correctly in Opera, but not in FF or IE. I'm retroactively adding the statement...
11
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
8
by: hobosalesman | last post by:
Consider the following (where 'a' is an anchor element with a valid URL href): a.onclick=help_mode; function help_mode() { alert("hi"); return false; } As expected clicking on the link now...
5
by: Magician | last post by:
Hello. I am trying to set the onclick event for images through a function, but the event is triggered as soon the page loads, then will not work when the image is clicked. Can anyone suggest what...
1
by: garey | last post by:
Hello - I have written a small table of contents manager. If an entry has sub-entries, it has a plus in front of it. If the user clicks on the plus, the sub-entries are displayed. The table of...
7
by: WSPL5 | last post by:
I have done this function before and I cannot figure out why it is not working. I am receiving the results of an xmlhttp call and I am looping through the values I am creating links with an OnClick. ...
4
by: donpro | last post by:
Hi, I've created a table where the header columns link to an AJAX function which calls a PHP file and returns content - the purpose is to sort the table on the heading. The code snippet is:...
1
by: Amit1980 | last post by:
I have to toggle the arrow image on onclick event. Here is the code with the required functionility. What I want now is, when the page loads there will be right arrow images. The arrow should be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.