Question

Implement "Back" one html page button

Asked by: IT79637

I have  written a small Accounts Payable system to learn new technologies.  It is written in html and php5. It has a login page, a vendor search page, and a voucher entry page.  On the vendor search page, I type in a vendor name, click the Search button and a list of vendors matching my search criteria is displayed.  Please click this link to see an example: http://rs90tl.rapidshare.com/files/55688260/Vendor-Browse.png

Note: all of the data is bogus.  I downloaded company names from Commerce Department, street names from Vancover Canada, and then randomally added cities. addresses and zip codes.  It's all fiction.

Suppose an Accounts Payable Clerk does a vendor lookup that will select 100 vendors.  If I display 20 rows per page, that will require 5 pages.  I would like to add  "Next" and  "Back" buttons to the page.  The Next button would go to the database and get the next 20 vendors. The "Bac" button would redisplay the previous 20 vendors.  

Some thoughts while writing the question:
1. I can use the browser "Back" button if the clerk wants to go back a page.
2. I can click the  "Next" button to display the next group of 20 vendors.  This would be an application based button.
3. This seems awkward since the user would have to use a browser button and an application button.  Yuck!

How do I implement the "Back" button without having to go back to the database and reselect the previous 20 vendors?

Can this be done by programmatically caching the pages locally after they are displayed in the browser?  The "Back" button would access the saved pages? Can this be done?

I'm open for better ideas.  Please feel free to suggest them!!!

Thanks much,
Cheers!

Is there a PHP category?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-09-14 at 07:49:25ID22829020
Tags

back

,

button

,

implement

,

html

,

page

Topic

Scripting Languages

Participating Experts
2
Points
500
Comments
8

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. e-Commerce Application
    Hi! I'm looking for a good (PHP) e-commerce application that is fully (and relatively easy) customizable in regards to the design. I'm a web developer and am fairly good with PHP, so customizing should not be that difficult if I can figure out how to do it, i.e. there should...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ahoffmannPosted on 2007-09-15 at 02:47:49ID: 19897065

> 1. I can use the browser "Back" button if the clerk wants to go back a page.
  if you mean go back to previous rows it has to be a back button of your page not the browser's back button

> 2. I can click the  "Next" button to display the next group of 20 vendors.  This would be an application based button.
yes it has to be a button in your page

> 3. This seems awkward since the user would have to use a browser button and an application button.  Yuck!
yes

> How do I implement the "Back" button without having to go back to the database and reselect the previous 20 vendors?
you have to store the selection in server-side session object and hand over a session id identifying that session object uniquely to the user/browser, this (transporting the session id) is most likely done using cookies (if security is not that important:)

> Can this be done by programmatically caching the pages locally after they are displayed in the browser?
yes, see previous description

>  The "Back" button would access the saved pages? Can this be done?
either the pages back button, or if you have implemented sessions (see above) then the browser's back button works also

 

by: OmegaJuniorPosted on 2007-09-15 at 07:29:46ID: 19897603

If your visitors' browsers support the navigation bar (Opera natively, Firefox with an extension, MSIE users luck out) you can add link elements to the page header, stating where the browser needs to go (up, down, next, previous, first, last, etc.).

That way, the visitor can use the same navigation bar (application buttons) for both the next and the previous set.

Obviously you'll still need to create a duplicate for moronic browsers like Microsoft's excuse.

 

by: IT79637Posted on 2007-09-24 at 15:01:00ID: 19952099

Sorry I took so long to respond.

As OmegaJunior suggested, I downloaded a Firefox navigation bar and for some reason it did not work on my application.  I don't believe it is a problem with the navigation bar, but rather an issue with my applicaton.

I next tried to program it using a combination of php and javascript history.back() and history.forward(). The history.back() works fine.  However, I ran into a problem on the "Next" button. Suppose you go forward 10 pages and then back 5 pages.  Initially going forward 10 page requires SQL to get the next 20 vendors to display on each of the 10 pages. Secondly, when I go back 5 pages, I can simply use javascript document.back().  Thirdly, if I want to go forward 5 pages, when I click the Next button, I go back to my database to get the next set of vendors for pages 6 - 10.  I only want to hit my database when it is necessary.  My programming keeps track of what page I am on, how many pages I have gone forward and the maxinum number of pages I can go forward.   For example, if I am on page 5, I know I can use document.forward() for pages 6-10.  For pages 11,12, etc..., I know I have to hit my database.

My Next button is a submit button.  Is there a way I can programatically change the behavior of it to use the document.forward() or to hit my database?  I believe the answer is yes.  When I reenter my program, I know if the page has been created. If it has beencreated, I can issue document.forward() and drop out of my program. Otherwise, this requires going to the database.  I can do that since that is already in my program.

Is this a workable solution?  Have a better idea? I don't have my ego in this.


Thanks much!

 

by: ahoffmannPosted on 2007-09-25 at 13:23:26ID: 19958743

sounds like you miss that you only can use document.forward(), history.next() if there was a hixtory.back() (or use of th eback button) right before ...

 

by: IT79637Posted on 2007-10-11 at 08:26:42ID: 20058130

Hi,

First I've upped the point to 500.

I have made one enhancement to the browse function.  I require the operator to enter sufficient search criteria so that no more than 300 rows are returned  or max. 15 pages.  I think that,  from a practical functional and database resources perspective, is quite generous for the operator.

This little project has turned into somewhat of a nightmare.  The ideal solution to me is to implement Back and Next buttons using javascript, except when I have to hit the DB, and do not take an unnecessary php  trip to the server and back.  For example my Back and Next Buttons would be defined as follows:

<input type="btn1" value="Back"  onClick="history.back()" />      (not submit button)
<input type="btn2" value="Next"  onClick="history.forward()"/>  (not submit button)

My Next button when I have to hit the DB is:
<input  type="submit" value="Next">

Using browser history is a double edged sword.  On one hand it is easy to implement history.back() and history.forward().  On the other hand, it creats a few problems:

1. It makes it very difficult to keep my php navigation variables in sync with which keep track where I am at in the browse: $onPage, $maxPages (viewed), and $totalPages.  Javascript and php variables don't cross language boundaries very easily.

2. If I start a new browse and  Next to page 5, then hit the Back button 3 times ( on page 2), the Next button on page 2 is defined as hit the DB (e.g. that how it was defined when I origionally displayed page 2).  So when I click it I hit the DB to get to page 3.  I want to execute history.forward().

This approach is clearly wrong.


My latest effort was to define all my buttons as submit buttons:

Back javascript:
<input type="submit" value="Back" class="font-filler-button" onClick="this.form.$whichButton.value=this.name;" name="PJ" />  

Next javascript:      
<input type="submit" value="Next" class="font-filler-button" onClick="this.form.$whichButton.value=this.name;" name="NJ" />

Next hit DB:
<input type="submit" value="Next" class="font-filler-button" onClick="this.form.$whichButton.value=this.name;" name="ND" />

Note, I gave each button a name. PJ is Back using javascript, NJ is Next using javascript and ND is Next hitting the DB.

When I click the button, my program gets the navagation variables ($onPage, $maxPage & $totalPages) and determines which button was clicked.

If it is DB, I hit the database and increment and save the the $onPage and $maxPages vars  to a file and display my page.

If it is PJ or NJ here is my code:

I store my location data is a local file. It looks like this: 4|4|244  The variables are $onPage, $maxPages and $totalPages respectively.  In this case I've gone out 5 pages and stopped.

$contents = readPageNav();     //get the data from a local file
$line = explode("|", $contents);
$onPage = $line[0];
$maxPages = $line[1];
$totalPages = $line[2];


$whichButton=$_POST['$whichButton'];
switch ($whichButton) {
  case "PJ":
    if ($onPage > 1) {
      $onPage--;
      writePageNav($onPage, $maxPages, $totalPages, $lastVendor); //function to update nav file variables
      echo  '<script language="javascript"> history.back() </script> ' ;   //DOES NOT WORK
    exit();
    }
  case "NJ":
    if ($onPage < $maxPages) {
      $onPage++;
      writePageNav($onPage, $maxPages, $totalPages, $lastVendor);
      echo  '<script language="javascript"> history.forward() </script>' ;  //DOES NOT WORK
    exit();
    }
  default:
    break;
}

....
remainig code handles DB access, presentation and displaying buttons.

The echo statement, which execute javascript do not work. If I go out 5 pages, the nav variables are: 5|5|244 which is correct. When I hit the Back button twice, the nav variables are: 3|5|244, BUT I stay on page 5. This mean history.back() did not execute.  

--->>>  Any ideas on how I can get get the javascript to execute as shown above?  <<<---


I've thought about making links like you see on blogs:
<Previous> <1> <2> <3>... <14> <Last>

But this pesents its own set of problems.  My DB browse has to read the entire results of the search criteria, save every 20 row and store the name in an array so I can keep track of the first vendor on each page.  My SQL would have to be something like this:

$nextVendor = vendorArray[$onPage + 1];  //returns first vendor name on page 6

SELECT * FROM vendor  WHERE name >= '$nextVendor ' ORDER by name LIMIT 20;


--->>> Can someone suggest a better approach?  <<<---

Thanks much!

Cheers!

 

by: IT79637Posted on 2007-10-11 at 10:09:03ID: 20059037

Another question, it it possible to add code to the end of my url so each page is uniquely identified.  Now the url on each page (1...15) looks like this:

http://localhost/ap/vndrSearch2.php

Can I add a page number at the end of the url like this and transfer to the 3rd page since it is unique?  For example:

header("location:vndrSearch2.php?page=3");

I know this is a method to pass a small amount of data between programs, but can it be treated las a unique url too?

Thanks again.

Cheers.

 

by: ahoffmannPosted on 2007-10-11 at 12:08:42ID: 20060055

> I know this is a method to pass a small amount of data between programs, but can it be treated las a unique url too?

http://localhost/ap/vndrSearch2.php/page/3
http://localhost/ap/vndrSearch2.php/3

According your code: I higly recommend that you implement all the logic server side and get rid of any malware (aka JavaScript;-)

 

by: IT79637Posted on 2007-10-25 at 08:03:57ID: 20148229

After struggleing with trying to implement a solution that uses both client (js) and server (php) code
, I took your advice and dumped the js.  I googled pagination on the web and found tons of ideas on how to navigate multiple pages in a browse function.  It uses links as follows:

First  <1> <2>  -3-  <4> <5> Last  in this case, page 3 is displayed.

The code is from http://www.sampsonresume.com/.  He has a video on how to do pagination.  It is very good!

It's not as efficient as I had hoped with using back/next buttons using browser history and only hitting the db once for each page.  But it works and it has added features, such as being able to jump forward several pages.

Thanks for your help and patience!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...