Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6335703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:54:29+00:00 2026-05-24T18:54:29+00:00

So I have a table with X rows in it. I have the following

  • 0

So I have a table with X rows in it. I have the following HTML code:

<tr id='row1' onClick="FormTRClick('1')"><td><a href='#'>Bla</a></td></tr>
<tr id='row2' onClick="FormTRClick('2')"><td><a href='#'>Bla</a></td></tr>
<tr id='row3' onClick="FormTRClick('3')"><td><a href='#'>Bla</a></td></tr>
<tr id='row4' onClick="FormTRClick('4')"><td><a href='#'>Bla</a></td></tr>

Now, when you click on the hyperlink ‘Bla’ you will also activate the OnClick event. Is there a way to only trigger the OnClick event when you don’t click on an object (like button, image, href) but only on the table row itself?

My FormTRClick() function looks as follow:

function FormTRClick(ctrl) {
   if (document.getElementById('chk' + ctrl).checked == true) {
    document.getElementById('chk' + ctrl).checked = false;
   } else {
    document.getElementById('chk' + ctrl).checked = true;
   }
}

I know I could also use the inverse document.getElementById('chk' + ctrl).checked = !document.getElementById('chk' + ctrl).checked but that’s not the point, I have extra code in there.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:54:30+00:00Added an answer on May 24, 2026 at 6:54 pm

    You’ll want to attach an event listener to those clicks, and stop the propogation:

    https://developer.mozilla.org/en/DOM/event.stopPropagation


    Alternatively, you can check for the target element:

    HTML:

    <tr id='row1' onClick="FormTRClick(event, '1')"><td><a href='#'>Bla</a></td></tr>
    <tr id='row2' onClick="FormTRClick(event, '2')"><td><a href='#'>Bla</a></td></tr>
    <tr id='row3' onClick="FormTRClick(event, '3')"><td><a href='#'>Bla</a></td></tr>
    <tr id='row4' onClick="FormTRClick(event, '4')"><td><a href='#'>Bla</a></td></tr>
    

    Javascript:

    function FormTRClick(event, ctrl) {
        if (event.target.tagName != 'A' && document.getElementById('chk' + ctrl).checked == true) {
            document.getElementById('chk' + ctrl).checked = false;
        } else {
            document.getElementById('chk' + ctrl).checked = true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which is parsing a HTML table as simply as
I have the following jQuery code for finding the sum of all table rows,
I have the following html. Its a table that can contains many rows id=rows_x.
I have a simple html table which has several rows. the following is implemented
I have a the following table with rows: =============================================== id| name | group1 |
I have table rows of data in html being filled from a CGI application.
how remove html table rows after 2nd row? if in table have 5 row,
I have an HTML table which may contain thousands of rows (number of columns
I have a HTML table with following content. <table class='main'> <tr id='r1' class='tbl'> <td>V1</td>
I have a html table and press a key in a table cell. Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.