This question refers to this sample page on my test site:

The following section of PHP code:

<table cellspacing="0" cellpadding="0" border="0" align="right">
while($row = mysql_fetch_row($result2))
$active = $row[0];
$imagenum = $row[1];
echo "<tr><td><a name='placeholder$imagenum' href='display_tattoos_2009.php?in=$imagenum' onClick='swap('toppic','$imagenum')'><img class='opacity' name='$imagenum' id='$imagenum' src='tattoothumbnails/$imagenum.png' width='72' height='72' alt='$imagenum'></a></td></tr>\n";

does what I want I want it to do on the page, displays a CSS controlled table on the side of the site to allow viewers to click on tattoo images and get a larger view, plus several other photos of the same tatoo from different angles.

What I'm having trouble with is that when the page reloads, the scrollbar automatically goes back to the top of the table and you have to scroll all the way down again to see the next tattoo.

I tried changing the href to 'display_tattoos_2009.php?in=$imagenum#placeholder$imagenum' and to 'display_tattoos_2009.php#placeholder$imagenum?in=$imagenum', neither of which worked.

I tried using an onLoad in the BODY such as:

<script type="text/javascript">
function goToAnchor() {
location.href = "display_tattoos_2009.php?in=$imagenum#placeholder$imagenum";

using PHP to write the javascript and pass the variable, but again no luck.

I tried ouptutting the table as a form and using FOCUS(), still no joy.

Maybe it's the lack of sleep, maybe it's that I've been looking at this code different ways for nigh on 24 hours now (interspersed with other projects to get my mind away form actively working on it), but I am at an impass.

Any help?


<script type="text/javascript">
function goToAnchor() {
location.href = <?php echo sprintf('"display_tattoos_2009.php?in=%s#placeholder%s";', $imagenum, $imagenum); ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.