Disable onClick for row in 1 cell

Last post 11-10-2006 12:11 AM by pushp_aspnet. 1 replies.

Sort Posts:

  • Disable onClick for row in 1 cell

    11-09-2006, 2:48 PM
    • Member
      38 point Member
    • miles.mcgehee
    • Member since 10-20-2006, 2:11 PM
    • San Angelo
    • Posts 17

    I'm creating a web email page that has a table on it with the messages. I have an onclick event on a <a></a> tag that I would like to transfer to the entire row (its a javascript onclick function). I also have in each row a column where the user can click a LinkButton that will delete the message... The only problem is when I put the onclick event that opens the email on the entire row and someone clicks the LinkButton to delete it, it opens the message and deletes it.

     How can I disable the row's onclick event for 1 particular cell....

    /// <summary>
    /// Miles L. McGehee - Town & Country IT
    /// </summary>
    /// <param name="Description">IT Analyst/Programmer</param>
  • Re: Disable onClick for row in 1 cell

    11-10-2006, 12:11 AM
    Answer
    • Contributor
      2,209 point Contributor
    • pushp_aspnet
    • Member since 10-19-2006, 1:27 PM
    • Hyderabad,India
    • Posts 447

    Try the following:

    1)Add an id to the table like,

    <table id="mytable"

    2)put the below code inside head tag of your page:

    <script type="text/javascript" >

     window.onload = function(){
           
         var table = document.getElementById("mytable");
         var rows = table.getElementsByTagName("tr");
         for(i=0;i<rows.length;i++)
         {
            rows[i].childNodes[yourCellIndex].onclick = function(){event.cancelBubble = true;}
         }
         }

     </script>

     yourCellIndex = zero based index for the  cell you want to disable onclick, for the second cell in a row it will be 1.

     

    Hope this helps.

    cheers!! 

    Home Is Where the Wind Blows
    http://pushpontech.blogspot.com
Page 1 of 1 (2 items)