July 30, 2010, 10:04:54 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Always search the forum before posting !
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: history(-1) for a button to go back a page in a form, (not just prev page)  (Read 1901 times)
ThePiston
Full Member
***
Offline Offline

Posts: 175


« on: March 23, 2007, 03:32:54 am »

I need to 'go back' sinde a multiple page form, but not necessarily to the same page.  I may come from pages 4, 5, or 6 so I need a basic "back" redirect.  This code just takes my entire page back and basically starts my form over:

Code:
function ff_apptbackbutton_action(element, action)
{
    switch (action) {
        case 'click':
         history.go(-1);
            break;
        default:;
    } // switch
} // ff_apptbackbutton_action

Anyone know how to make the form go back to the prev page it came from and not necessarily the 'prev page'?
« Last Edit: March 23, 2007, 04:01:46 am by ThePiston » Logged
Bitsqueezer
Living Legend
******
Offline Offline

Posts: 1872



« Reply #1 on: March 24, 2007, 05:04:17 am »

Hi!

Don't know exactly what your problem is...

If you want to go back to form-page 1 in a form with 6 pages, just use "ff_page1()", if it should be a page greater than 3 you can use "ff_switchpage(pagenumber)" as you can see if you look into the scripts at "ff_page1()" for example.

If you want to go back to the last page the user had previously opened of one form then you could make a global variable in Javascript, for example in the Init-Script-part of the form outside the "function" and save the actual page from the variable "ff_currentpage" into it. When you want to switch back you can again use the function "ff_switchpage(lastpage)" for example (if "lastpage" was the name of your global variable) and overwrite the "lastpage"-variable with the new last page then.

If you want to switch between different pages through different forms it is a little bit more difficult: You must do something like save the name of the actual form and page of it and submit this to the next form which must read this parameter and use it for redirecting back. At the same time this one must submit it's own formname and page to the next (or last) one which must react to this and so on. A lot of work... Smiley

Cheers,

Christian
Logged
ThePiston
Full Member
***
Offline Offline

Posts: 175


« Reply #2 on: March 24, 2007, 12:39:45 pm »

i'll try the global variable trick, but I'm just bginning javascript.
Logged
olz
Newbie

Offline Offline

Posts: 2


« Reply #3 on: October 06, 2009, 03:29:10 pm »

Hi!

I could not make this work.

Quote
If you want to go back to the last page the user had previously opened of one form then you could make a global variable in Javascript, for example in the Init-Script-part of the form outside the "function" and save the actual page from the variable "ff_currentpage" into it. When you want to switch back you can again use the function "ff_switchpage(lastpage)" for example (if "lastpage" was the name of your global variable) and overwrite the "lastpage"-variable with the new last page then.

Could someone post a more detailed example?

Thanks!
Paulo Bubolz
Logged
ColinM
Newbie

Offline Offline

Posts: 20


« Reply #4 on: October 08, 2009, 03:04:21 am »

Hi
The solution depends if you are doing any submits and then doing any header() functions in the submit php pieces.
If you are just moving between form pages in javascript with say ff_page1 or ff-switchpage(target_page) then you can use either a global variable or a hidden element. Pages inside ff are NOT web pages but if you use a header() in a submit piece to return to your form then you are reloading the form so it will reinitialise.

Assume you have a hidden element called prev_page. Further assume your form starts at page 1 so when creating element prev_page set its vale to 1 (as an integer). In the custom button action scripts on each page that is to return to previous you put in something like
 
Code:
target_page = ff_getElementByName('prev_page').value;  //get the page number we came from
ff_getElementByName('prev_page').value = ff_currentpage;     //set prev_page to be the one we are just leaving
 ff_switchpage('target_page');

Actually you could make the above into a function called say go_back and put it in one of the buttons on say your start page
Code:
function go_back()
{
   var target_page = ff_getElementByName('prev_page').value;  //get the page number we came from
   ff_getElementByName('prev_page').value = ff_currentpage;     //set prev_page to be the one we are just leaving
   ff_switchpage('target_page');
   return;
}
You then just need to put a  go_back(); in each action button custom code that switches  back to a previous page.

In those buttons where you are not going back but you need to  return back to them the only line you need in the action code itself is
Code:
   ff_getElementByName('prev_page').value = ff_currentpage;     //set prev_page to be the one we are just leaving

Note this does not work if you do a submit as that will reload the form and reinitialise it.  Also the global variables are reset.  If you are doing submits then you will need to enter into php with before form and before submit pieces and use a parameter to remember contents of prev_page.  I recently wrote a note on that at in Basic Form topics "Database app return to sender redirection which may help a little http://www.facileforms.biz/forum/index.php/topic,6147.0.html
In your case you would be saving and restoring 'prev_page' element and using the go_back function as above
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by SMF © 2001-2006 Lewis Media
| Terms of Use | Privacy | Sitemap |