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 7566235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:21:43+00:00 2026-05-30T14:21:43+00:00

My page has 2 forms say form1 and form2. now when form one is

  • 0

My page has 2 forms say form1 and form2. now when form one is submitted, then I am setting the value of a hidden field in form 2:

$('#form1').submit(function (){
     $("#hiddenfield").val($(this).serialize()) ; 
     alert($("#hiddenfield").val());
    return true;
    });

$('#form2').submit(function (){
     alert($("#hiddenfield").val());
    return true;
    });

In the first alert the data is showing properly but when I am submitting the sencond form, the value is empty. What might be the issue?

  • 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-30T14:21:45+00:00Added an answer on May 30, 2026 at 2:21 pm

    The problem is probably that since your submit function return true, the browser will post the form, thus reloading your page. Therefore your second form is empty when you post it. If you don’t want the form to reload the page, your submit-function will have to return false, to stop the browser from posting the form the regular way. In that case you will of course have to post your form through ajax instead, as returning false from the submit-function will stop the form-posting all together.

    You can try to see if this is the problem by replacing the code you posted with the code below, and then try to first submit the first form and then the second. If the second form submit then alerts the actual value instead of empty, you have found the source of your problem:

    $('#form1').submit(function (){
         $("#hiddenfield").val($(this).serialize()) ; 
         alert($("#hiddenfield").val());
        return false;
        });
    
    $('#form2').submit(function (){
         alert($("#hiddenfield").val());
        return false;
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that has several ajax submission forms. Each form has a
I have 3 forms at the same page and each has a different form
I have an ASP.NET page which has a script manager on it. <form id=form1
Say I submit a simple page (that has no parameters, no forms, etc, and
I have a ASP.NET page which has a form on it. It also has
A form on my website's contact -us HTML page has two fields 1) subject
I have a html page with a form. The form has Div which gets
My page is a bulk order form that has many products and various size
I have a form on a page where the user has inputs to edit
Say I have this simple form: class ContactForm(forms.Form): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True)

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.