1

I was making a mailing sort of system.Now am stuck with a problem :

Suppose i have rows in table showing inbox messages and on click they show full message.Now with each row i want to have a checkbox,so that on checking that checkbox i can delete that particular row from the page.But as i had made whole row clickable,as soon as i check the checkbox it moves on to next page.

My code is something like this :

<tr bgcolor="#5D1B90" color="#FFFFFF" onmouseover="ChangeColor(this, true,false);" onmouseout="ChangeColor(this, false,false);" onclick="DoNav('showmail.jsp?mid=<%=messageid%>');">    
<td callspan="3"><%=sendername%>  :   <%=messagesubject%>      <%=sendingtime%></td>
</tr>

Here onNav function is :

function DoNav(theUrl)
{
   document.location.href = theUrl;
}

So how to make it work according to requirement?

Also i want sendingtime of each row to be right aligned and subject to be center aligned in row.How to do this ?

user3462609
  • 105
  • 2
  • 11

1 Answers1

0

You need to stop your checkbox click propagate to the parent TR

event.stopPropagation();

Also, you cannot have nothing in-front of a tr element but another tr element. Put your checkbox inside an tr inner td element.
You also have a typo in your HTML callspan :) should be **colspan**

LIVE DEMO

<td colspan="3">John  :   "Hello"      10:00</td>
<td><input type="checkbox" onclick="DoRemove(event);"></td> 

JS:

function DoNav(theUrl){
   document.location.href = theUrl;
}
function DoRemove(e){
    if (!e) e = window.event;
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
    // Remove code here.
}

stopPropagation without jQuery

Community
  • 1
  • 1
Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313
  • And how to increase the length of each row of the table and also what if i want this 10:00 to extreme right and "Hello" in the middle of row? – user3462609 Apr 04 '14 at 01:21
  • @user3462609 what you mean by *increase length of each row?* (Use CSS to position your elements as needed, I hope the above answers your question) – Roko C. Buljan Apr 04 '14 at 01:25