Arnold Porche Villaluz
Arnold Porche Villaluz

Reputation: 213

How to call Colorbox effect (example7) with javascript onclick event

I have an alternating rows using PHP:

while($i < $num)
            {
            $idphysicians = mysql_result($qPhysician,$i,"idphysicians");
            if ($i % 2 == 0){
            echo "<tr class='even' onclick=\"DoNav('physicianUpdate.php?idphysicians=$idphysicians');\">";
            }
            else{
            echo "<tr class='odd' onclick=\"DoNav('physicianUpdate.php?idphysicians=$idphysicians');\">";
            }
            echo "<td>" . mysql_result($qPhysician,$i,"lastName") . "</td>";
            echo "<td>" . mysql_result($qPhysician,$i,"firstName") . "</td>";
            echo "</tr>";

I called the DoNav javascript function to open the link when the row from my table is click:

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

I also have a colorbox effect to add another physician using an ahref link. This one works:

<a class='example7' href="physicianAdd.php" title="Add a Physician"><img src="images/icons/add.png" height="20"/> Add a Physician</a>

How can I add the same colorbox effect to my clickable table rows above? Since I already have a tr class even or odd, can I still add another class (example7) to it?

By the way, example7 from colorbox can be found here: http://colorpowered.com/colorbox/core/example1/index.html

it's the demo "Outside Webpage (Iframe)"

Upvotes: 1

Views: 2101

Answers (1)

Dr.Molle
Dr.Molle

Reputation: 117334

Elements may have multiple classes,

<tr class='even example7'>

But you don't need a class here, call the colorbox directly:

function DoNav(theUrl)
{
  $.colorbox({href:   theUrl,
              iframe: true,
              width:  '80%', 
              height: '80%'});
}

Upvotes: 2

Related Questions