473,569 Members | 3,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3704
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.htm l>
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.ht ml>
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
9927
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 links in my fireworks-generated dhtml popup menus. Does anyone here know where I would add this javascript fucntion in the code so that it would be...
3
3246
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 "return promptBeforeOpening();" FF and IE rewrite it as I would expect them to, but it turns out that that doesn't work (no disclaimer pops up, and...
11
2992
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. It works perfectly (assigning the correct images and the correct onclick events to the correct <atags):
8
1564
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 results in a "hi" but no change in location, the link isn't followed because onclick returned false. Now look at what I thought was the same thing:
5
2080
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 is wrong? It is happening in both IE6 and Firefox --------------------------------------------------------------------------- window.onload =...
1
2838
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 contents is displayed in one frame and the pages of the document in the other. Clicking on a table of contents entry redraws the image in the page...
7
2000
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. I created a simple function with just an alert, but the link is not kicking off the function. I have several examples of the same process working on...
4
3659
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: <th scope="col"><a href="javascript:;" onclick="loadBookingContent('<? php echo $SERVERPAGE_URL . SORT_BY_BOOKING; ?>','innerhbl')">Booking</ a></th>
1
5897
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 chenge to down arrow when I the row expands to dispaly the child links. and if the collaps to hide child link the arrow should change back to right arroe...
0
7619
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.