• 0

[JS] Go back and submit


Question

I have previous and next buttons on the form I am working on, but I'd like so that if somebody hits the previous link - it submits the form and then goes back a page.

Here is my next link, <a href="java script:document.form.submit();">next

So, somehow using history.go(-1);, it would first SUBMIT and then go back a page.

Thanks!

Link to comment
https://www.neowin.net/forum/topic/528588-js-go-back-and-submit/
Share on other sites

9 answers to this question

Recommended Posts

  • 0

You should NEVER use client side scripting for site navigation.

Instead, use a PHP backend.

Basically you link to the backend, say to /go.php?act=next

and in your php file the logic is this

post information

if act next

header (increment link #) (so this would go from page 2 to page 3)

else if act previous

header (decrement link #) (and this would go from page 2 to page 1)

else error or something

assuming that you're using numbers for the pages of course. if you have names that dont follow a patter then it'll be some more code.

  • 0
  Kudos said:
You click "next" to go to the next page right? So make next a submit button for the form. Store these post variables in the session and deal with the next page.

The problem is submit goes forward. I want it submit and then go back a page.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

  • Recent Achievements

    • First Post
      Gladiattore earned a badge
      First Post
    • Reacting Well
      Gladiattore earned a badge
      Reacting Well
    • Week One Done
      NeoWeen earned a badge
      Week One Done
    • One Month Later
      BA the Curmudgeon earned a badge
      One Month Later
    • First Post
      Doreen768 earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      641
    2. 2
      ATLien_0
      256
    3. 3
      Xenon
      165
    4. 4
      neufuse
      142
    5. 5
      +FloatingFatMan
      107
  • Tell a friend

    Love Neowin? Tell a friend!