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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:53:05+00:00 2026-05-12T06:53:05+00:00

I have a page with 2 forms and a hidden field that is outside

  • 0

I have a page with 2 forms and a hidden field that is outside of both of the forms.

How can the hidden field be submitted with either of the forms?

I thought about doing something like this with jQuery:

<script type="text/javascript">
    $(function() {
        $('form').submit(function() {
            // do something to move or copy the
            // hidden field to the submitting form
        });
    });
</script>

Will this work? Any other ideas?

EDIT

The hidden field stores a serialized object graph that doesn’t change. Both server methods require the object. The serialized object string can get pretty hefty, so I don’t want this thing sent down from the server 2 times.

  • 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-12T06:53:05+00:00Added an answer on May 12, 2026 at 6:53 am

    You can simply inject a copy of the element into each form right before submission.
    This way, you can have the option of having different information for each hidden form field without affecting the other.


    Something like this:

    <script type="text/javascript">
        $(function() {
            $('form').submit(function() {
                $("#hidden_element").clone().appendTo(this);
            });
        });
    </script>
    

    If you want to use the exact same element for both forms without creating a fresh copy, just don’t use clone()


    See documentation for clone() and for appendTo()

    EDIT:

    If you don’t want to send the hidden element with every request the form sends. Consider storing it in the database for that user for that time. You can submit its content once, and once only for every page reload, and then just send the database id of the hidden element with each form post.

    On page load, something like this:

    $.post("page.php", { reallyBigObject : $("#hiddenfield").val() }, function(insertedID){
      $("#hiddenfield").val(insertedID);
    });
    

    Then, in the server side code:

    //insert $_POST["reallyBigObject"] into databse
    //get the just inserted id (in php it's done with mysql_insert_id())
    //echo, or print the just inserted id, and exit
    

    This way your js gets the callback.

    Now, you can submit the form as you would, but this time, you’re only sending the id (integer number) to the server.
    You can then simply delete the object from your server (run a cron to do it after X amount of time, or send another request to delete it.

    Honestly, though, unless you object is HUGE(!!), I think storing it by submitting it only once is a lot more complex to execute than to simply send two requests to the server.

    Let me know if you have any other questions…

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

Sidebar

Related Questions

I would like to have an aspx page that contains something like.... <form id=form1
I have a series of forms on a page that all have a recordId
I have a form with a bunch of checkboxes, and a hidden field that
I have a page with many forms in panels and usercontrols, and a requiredfield
I have a page with many forms on it. could be 1..200. None of
I have a web page with 3 forms on it. Not nested, just one
I have forms in my page a get and a post and i want
I have two forms on a page (one is being grabbed by AJAX). I
I have created a user login page and am using Forms Authentication. Users are
I have a form on an HTML page with multiple submit buttons that perform

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.