Forum Moderators: open

Message Too Old, No Replies

onClick and hyperlink problems

         

tbthorpe

2:15 pm on Jul 26, 2004 (gmt 0)

10+ Year Member



Hi -
I've created a dynamic table from a database on my website. The general idea of the table is you get a summary of a document in each row, and by using the onClick functionality, you can open a new page with the complete document by clicking anywhere in the row. I also added into the table a hyperlink that users can click on to edit the document. The problem is, when i click on the link, both the functionality of the link goes through, as long as the call to the onClick method...so basically, i have two things happening when i only want to have one. How do i stop onClick from being performed when i'm clicking a hyperlink? Thanks!

Mr_Brutal

2:20 pm on Jul 26, 2004 (gmt 0)

10+ Year Member



Im pretty sure a "...; return false;" in the onClick method will.. return false and stop the href part of the link happening. If im wrong then you'll wait till someone tells you the real answer and laughs at my post, sorry :)

tbthorpe

3:09 pm on Jul 26, 2004 (gmt 0)

10+ Year Member



Well when i click on the link, i want the href part to work, but not the onClick. I think you answered for the opposite problem...can you clarify?

tim

encyclo

3:15 pm on Jul 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I understand your problem correctly, you have an onclick event on a table row, and within that row you have a standard hyperlink. Your problem is that the onclick even overrides the hyperlink.

If that is the case, have you tried specifying another onclick event just for the hyperlink which duplicates the hyperlink action? I haven't tested this, but I reckon it should work as the second onclick event is more specific than the table-row one.

A short markup snippet of what you are currently doing would help greatly in this case, I think...

Mr_Brutal

3:25 pm on Jul 26, 2004 (gmt 0)

10+ Year Member



Sorry your right - i didn't read the question fully! Man you'd think id know that by now!

I can't actually think of any way round it now - do you need the onClick method for the whole row! If it were me id maybe make the cells onClick instead but not the one witrh the link in it.

Like above some code would be useful!