Jump to content

row checkbox that doesn't interfere with row onclick event


RLJ

Recommended Posts

I have the following code to generate a table of results from a MySQL query. As you can see, some of the rows contain onclick, onmouseover & onmouseout events.

 

$table = "<table border='0' cellpadding='5' cellspacing='0' width='460px'>
$i=1;
        while($arr = mysql_fetch_array($result, MYSQL_NUM))
        {
            $table .= "<tr onclick=\"expandcollapse('subb".$i."a', 'subb".$i."b', 'subb".$i."c')\" onMouseOver=\"this.bgColor='gold'; this.style.cursor='pointer';\" onMouseOut=\"this.bgColor='#FFFFFF';\"> <td style='border-left: 1px solid #808080; border-bottom: 1px solid #808080;'> ±  ".$arr[0]." ".$arr[1]."</td>"
                          ."<td style='border-bottom: 1px solid #808080;'>".$arr[2]."</td>"
                          ."<td style='border-bottom: 1px solid #808080;'>".$arr[3]."</td>"
                          ."<td style='border-bottom: 1px solid #808080;'>".$arr[4]."</td>"
                          ."<td style='border-bottom: 1px solid #808080; border-right: 1px solid #808080;'>".$arr[5]."</td></tr>"
                     ."<tr id='subb".$i."a'; style='display:none';><td colspan='5' style='border-bottom: 1px solid #808080; border-right: 1px solid #808080; border-left: 1px solid #808080;';> ".wordwrap ($arr[6], 53, '<br />',$cut = true)."</td></tr>"
                     ."<tr id='subb".$i."b'; style='display:none';><td colspan='5' style='border-bottom: 1px solid #808080; border-right: 1px solid #808080; border-left: 1px solid #808080;'> ".wordwrap ($arr[7], 53, '<br />',$cut = true)."</td></tr>"
                     ."<tr id='subb".$i."c'; style='display:none';><td colspan='5' style='border-bottom: 1px solid #808080; border-right: 1px solid #808080; border-left: 1px solid #808080;'> ".wordwrap ($arr[8], 53, '<br />',$cut = true)."</td></tr>";
        //echo $i;
        $i++;
        }
        $table .= "</table>";
        echo $table;

 

I now want to add a checkbox to these rows, but I don't want the row onclick event to happen when the checkbox is clicked. How do I do this?

 

Is there a way to run somefunction(thisrow) instead of somefunction(this)? Because that way I could specify an onclick event for each individual cell that affects the whole row and just add an extra column with checkboxes that doesn't have this onclick event.

 

Thanks!

Link to comment
Share on other sites

You'll probably have more luck on the JavaScript thread since you're asking about JavaScript, not PHP.

 

Try doing an individual onclick/onmouseover/onmouseout for the cells instead of the row.  If the row is actually doing something, then grab the row by its ID (give it one) and act on the row.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.