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

  • Home
  • SEARCH
  • 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 6553713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:36:53+00:00 2026-05-25T12:36:53+00:00

I am trying to do a form submission without having the page reload. It

  • 0

I am trying to do a form submission without having the page reload. It works the first time, but when I try and do a second submission the page is refreshed.

I would like to be able to do several submissions with the new data propagating into the current element. What am I missing.

Here is my first page form.php

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  <html>
    <head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>

<script type="text/javascript">
    //<![CDATA[
    jQuery.noConflict();
    jQuery(document).ready(function () {
        jQuery("#form").validate({
            debug: false,
            submitHandler: function (form) {
                jQuery.post('formPost.php',
                    jQuery("#form").serialize(), function (data) {
                    jQuery('#Box').html(data);
                });
            }
        });
    });
    // ]]>
</script>

  </head>
  <body>
    <div id="Box">
      <form id="form" name="form" method="POST" action="">
        <select name="color">
          <option>red</option>
          <option>white</option>
          <option>blue</option>
        </select>
        <input type="submit" name="submit" value="submit" /><br />
      </form>
    </div>
  </body>
</html>

and here is my second page formPost.php

<?php

  switch ($_POST['color'])
  {
    case 'red':
      echo 'you chose red<br /><br />';
      break;

    case 'blue':
      echo 'you chose blue<br /><br />';
      break;

    case 'white':
      echo 'you chose white<br /><br />';
      break;
  }
?>
<form id="form" name="form" method="POST" action="">
  <select name="color">
    <option>red</option>
    <option>white</option>
    <option>blue</option>
  </select>
  <input type="submit" name="submit" value="submit" /><br />
</form>

I want to be able to reuse the same form for multiple form submissions while staying on the same page and having the data apprear in the same div without refreshing the page. Any ideas

  • 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-05-25T12:36:54+00:00Added an answer on May 25, 2026 at 12:36 pm

    Try this:

    <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
        <head>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
        <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
    
    <script type="text/javascript">
        //<![CDATA[
        jQuery.noConflict();
        jQuery(document).ready(function () {
            initializeForm();
        });
    
        function initializeForm() {
            jQuery("#form").validate({
                debug: false,
                submitHandler: function (form) {
                    jQuery.post('formPost.php',
                        jQuery("#form").serialize(), function (data) {
                        jQuery('#Box').html(data);
                        initializeForm();
                    });
                }
    
            });
        }
    
        // ]]>
    </script>
    
      </head>
      <body>
        <div id="Box">
          <form id="form" name="form" method="POST" action="">
            <select name="color">
              <option>red</option>
              <option>white</option>
              <option>blue</option>
            </select>
            <input type="submit" name="submit" value="submit" /><br />
          </form>
        </div>
      </body>
    </html>
    

    I tested this out and it works locally for me. I hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First time asking a question here. Usually I can find my answer without having
I'm trying to make a page that takes a form submission and adds the
I was trying to test form submission using mouse clicks but the form doesn't
so I'm trying to intercept a javascript form submission using jquery, and having some
I have a page with a form where I'm trying to prevent duplicate submission,
Trying to add a 'box' to a form at design time, I looked up
Im trying to submit a specific form programatically, but I allways get the initial
I am trying to validate a form submission in Kohana 3. I have the
I am trying to get an autocomplete working and making an Ajax form submission
I was trying out Rails again, this time the 3 version, but I got

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.