Jump to content

Move to anchor after posting


tjohnson_nb

Recommended Posts

I have an application that creates quotations, orders etc. and as the user adds items the page reloads and can quite long. The problem is then the user has to scroll down to the last item to add another one - this gets to be quite time-consuming. Is there a way I can get it to do this automatically? I have tried putting anchors on each line item like this;

echo "<form action='display_quotation.php?item=$detail_number' method='post'>\n";
.........
echo "<a name='item_$detail_number'></a>\n";

and put the javascript ;

<script type='text/javascript'>
function goToAnchor() {
window.location.hash='#item_$item';
}
</script>
</head>

<body onload='goToAnchor();' >

 

This doesn't seem to work - I get in the URL  http://my_domain/display_quotation.php?item=3#item_3 but the page always goes to tiem no matter what item is passed via post.

Link to comment
https://forums.phpfreaks.com/topic/253688-move-to-anchor-after-posting/
Share on other sites

I suppose you have a function that handles the item addon.

What you can do is use an header(); in the end of the function that redirect to the added item. like so:

 

header("Location: http://yourdomain.com/display_quotation.php?item=$detail_number");

 

or

 

header("Location: http://yourdomain.com/display_quotation.php#$detail_number");

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.