Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reload text search anchor problem .

Status
Not open for further replies.

dessie1981

Programmer
May 9, 2006
116
GB
Hi Everyone.

I have designed an online store in php and making a few tweaks.

At the moment i am having a problem with my anchors.

When i add something to the basket i reload the page and pass a parameter indicating the anchor, the anchor is the part number of the product that the user has selected. The results are in table format btw.

The problem is that on reload the text search(anchor) is returning the search result to the top of the page, is there any way of returing the search to the middle of the page??

Any help would be great

Regards
Dessie
 
how are you setting your anchors in the html?

and when you say that that you "pass a parameter indicating the anchor" what do you mean? can you give an example? i'd guess you mean adding a "#anchor" to the end of a header("Location:..."); call

do you get the same behaviour in all browsers?
 
Hi Jpadie,

The anchors are working fine - returning the anchor to the top of the screen.

Is there any way to return the anchor to the same position on the screen that the user was viewing before the reload of the page.

I mean the product they are viewing may be on the 150th row on the result table. The anchor is returing this result to the top of the screen , when the user may have had this result on the bottom of the screen, therefore they may get confused.

Hope you catch my drift!

e.g. if the user is looking at a table of results

Regards
Dessie
 
sure. you just have an anchor for each row. this should be relatively easy as the rows will be delivered to the browser dynamically.

eg
Code:
while ($row = mysql_fetch_assoc($result)):
echo <<<ROW
<tr id="row_{$row['productID']}">
 <td>{$row['productID']}</td>
 <td>{$row['productDescription']}</td>
 <td>{$row['productPrice']}</td>
 <td>
     <form action="{$_SERVER['PHP_SELF']}" method="POST" style="display:inline">
     <input type="hidden" name="productID" value="{$row['productID']}" />
     <input type="submit" name="submit" value="2 Basket" />
     </form>
 </td>
</tr>
ROW;
endwhile;

with the above, you can then add the anchor to the redirect by this
Code:
header("Location:".$_SERVER['PHP_SELF']."#row_".trim($_POST['productID']));
 
Oh yeah should have thought of that, thanks a million

Regards
Dessie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top