tjohnson_nb Posted December 22, 2011 Share Posted December 22, 2011 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. Quote Link to comment Share on other sites More sharing options...
MarPlo Posted December 24, 2011 Share Posted December 24, 2011 Hi, I'm not shure if will work, but try with jQuery and focus() Add a CSS class in that <a> <a class="cls" name='item_$detail_number'></a> In JS: $('.cls:last').focus(); Quote Link to comment Share on other sites More sharing options...
shaiang Posted December 25, 2011 Share Posted December 25, 2011 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"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.