I have a site that has a Details button on every row in the table. When the button is clicked, the details section for that row expands or collapses. The problem is this. If you're halfway down the page and click that button, you're taken to the top of the page. How do I get it to where it stays where you are?
Here's the jquery:
function WireEvents(count)
{
$('.details'+count).toggle(function() { $(this).closest('.innercontent').find('.details'+count).css('display', 'inline') },
function() { $(this).closest('.innercontent').find('.details'+count).css('display', 'none') }
);
}
And here's the html/php:
<div id="innercontent">
<?php
echo "<div id=\"instructions\">";
echo "To perform another search, please go back to the <a href=\"index.php\">homepage</a>.";
echo "</div>";
while($data=@mysqli_fetch_array($result))
{
++$cnt;
echo "<div id=\"tbl\">";
echo "<table><tr><td class=\"product\">";
$pn=$data['ProductName'];
$filename=$data['Filename'];
$finalpath=$path.$filename;
$manufacturer=$data['Manufacturer'];
$productnumber=$data['ProductNumber'];
$commonname=$data['CommonName'];
$date=$data['Date'];
echo "$pn";
echo "<div class=\"details$cnt hide\">";
if($commonname=="")
{
echo "<p><span class=\"boldcolor\">Manufacturer:</span> $manufacturer <br /><br />";
echo "<span class=\"boldcolor\">Product Number:</span> $productnumber <br /><br />";
echo "<span class=\"boldcolor\">Date:</span> $date";
echo "</p>";
}
else if ($productnumber=="")
{
echo "<p><span class=\"boldcolor\">Common Name:</span> $commonname <br /><br />";
echo "<span class=\"boldcolor\">Manufacturer:</span> $manufacturer <br /><br />";
echo "<span class=\"boldcolor\">Date:</span> $date";
echo "</p>";
}
else if($commonname=="" && $productnumber=="")
{
echo "<p><span class=\"boldcolor\">Manufacturer:</span> $manufacturer <br /><br />";
echo "<span class=\"boldcolor\">Date:</span> $date";
echo "</p>";
}
echo "</div>";
echo "</td>";
echo "<td><a class=\"imgdetails\" href=\"#\"><img src=\"./images/details.png\" onclick=\"WireEvents($cnt);\" /></a></td>";
echo "<td><a href=\"$finalpath\" target=\"_blank\"><img src=\"./images/view.png\" /></a></td>";
echo "</tr>";
echo "</table>";
echo "</div>";
}
echo "<div class=\"page\">";
//include('/library/pagination.php');
echo "</div>";
?>
</div>