Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8899969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:59:18+00:00 2026-06-15T00:59:18+00:00

I have a multi page form, navigable both by forward and back buttons, but

  • 0

I have a multi page form, navigable both by forward and back buttons, but also via a side bar menu.

I want to avoid data that has been entered on the current page being lost, if the user leaves the page via the sidebar menu navigation:

Desired Goal:

When a user clicks the link in a menu, the “action” attribute of the form, is adjusted to match the destination of that link. As there are several pages, I’d rather not hard code several “if link to page1.php is click, then make the action equal page1.php etc”, so much as a function that can be called on click of a link, and will set the action to whatever the link destination is.

My attempt:

(I’m learning JavaScript, so I really am stabbing about in the dark a bit, I’d like to understand this better)

Here is my html

<form id="myform" action="default_action.php" method="POST">

... form inputs...

<input type="submit" name="DefaultSubmit" value="Next Page">
</form>


<div id="navmenu" class="navmenu">
    <ul id="sidebarmenu1">
        <li><a href="?page=1" class="menu1" onclick="OnMenuClick()">Page 1</a></li>
        <li><a href="?page=2" class="menu2" onclick="OnMenuClick()">Page 2</a></li>
        <li><a href="?page=3" class="menu3" onclick="OnMenuClick()">Page 3</a></li>
    </ul>
</div>

And here is my attempt at javascript:

<script>
function OnMenuClick()
{
document.myform.action ="this.getAttribute("href")"
document.myform.submit();
}
</script>

I stitched it together from reading various tutorials, but it seems like there are many ways to do one thing, and so far this isn’t working for me, any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:59:20+00:00Added an answer on June 15, 2026 at 12:59 am

    If you are willing to include jQuery on your site (and hey, everyone’s doing it 🙂 ), I would suggest the following:

    <form id="myform" action="default_action.php" method="POST">
    
    ... form inputs...
    
    <input type="submit" name="DefaultSubmit" value="Next Page">
    </form>
    <div id="navmenu" class="navmenu">
        <ul id="sidebarmenu1">
            <li><a href="?page=1" class="menu1">Page 1</a></li>
            <li><a href="?page=2" class="menu2">Page 2</a></li>
            <li><a href="?page=3" class="menu3">Page 3</a></li>
        </ul>
    </div>
    

    And the jQuery:

    $(function () {
        $('#sidebarmenu1 a').on('click', function (event) {
            var url = $(this).attr('href');
            $('#myform').attr('action', url);
            $("#myform").submit();
            event.preventDefault();
        });
    });​
    

    If you’re just getting into javascript, jQuery is a great place to get started and you can include it on your site just by adding to following to your <head> tag:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-page form, and I'm trying to implement Back buttons, so that
I have a multi-page form, aka a Wizard pattern, where Page 1 corresponds to
I have a multi-lingual page where I want to display form validation error in
I have a multi-page form. Each page posts data form one to the next,
I have a multi-step form and user can navigate to any page to modify
I have a multi page form that I am trying to implement on my
I am currently trying to create a multi-page form that uses both jQuery and
I have a multi-page form. I'd like to have a prev and next button
I have created a multi-page registration form for a website. Due to the page
I have a program which prints a multi-page document. The first page is pre-printed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.