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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:43:36+00:00 2026-05-27T07:43:36+00:00

I have an web page where form input elements are in different places and

  • 0

I have an web page where form input elements are in different places and cannot be physically contained within the same form. What’s the best approach to include these input values in the form submission?

Note that I want to perform an actual post submission, not an AJAX submission.

  • 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-27T07:43:37+00:00Added an answer on May 27, 2026 at 7:43 am

    Add an onsubmit handler to the form, and in the handler copy the values from the various inputs to hidden inputs that are in the form.

    Note however that this will (obviously) not work for users with JavaScript turned off.

    <form id="mainForm" action="yoururl">
       <!-- visible form fields here, then hidden
            fields to hold values from non-form fields -->    
    
       <input type="hidden" id="field1" name="field1">
       <input type="hidden" id="field2" name="field2">
       <input type="hidden" id="field3" name="field3">
       <input type="hidden" id="field4" name="field4">
    </form>
    
    <!-- other fields to be submitted with mainForm -->    
    <input type="text" id="displayfield1">
    <input type="text" id="displayfield2">
    <input type="text" id="displayfield3">
    <input type="text" id="displayfield4">
    
    <script>
       document.getElementById("mainForm").onsubmit = function(e) {
           e = e || window.event;
           var theForm = e.target || e.srcElement;
    
           // could copy fields across manually, one by one:
           document.getElementById("field1").value =
                                 document.getElementById("displayField1").value;
    
           // or you could copy based on matching field ids:
           var fields = theForm.getElementsByTagName("input"),
               i,
               df;
    
           for (i=0; i < fields.length; i++) {
               if (fields[i].type === "hidden") {
                  df = document.getElementById("display" + fields[i].id);
                  if (df != null)
                     fields[i].value = df.value;
               }
           }
    
           // could return false here if there was some failed
           // validation and you wanted to stop the form submitting
           return true;
       };
    </script>
    

    Sorry about the somewhat ugly code – just whipped something up off the top of my head. If you’re interested you could do all of the above in about three lines of jQuery…

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

Sidebar

Related Questions

Within an web form I have a some input fields <div id=search1> <div class=forminput>
I have a web page that allows users to insert form input objects with
I have a .aspx web page, with a html form within it, this also
Lets say we have a web page with a search input form, which submits
I have a web page like this: <form id=some-form> <input type='text'> <button type=submit> </form>
I have a single web page with master detail form/input layout. Currently the form
I have a simple web app: a web page with a form to submit,
I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down
I have an HTML page with a web form. Among other things, it includes
I use sitemesh for page decoration in my web app. I have a form

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.