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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:52:57+00:00 2026-05-25T09:52:57+00:00

In our application, we use document.forms[0] to access the form from JavaScript. This used

  • 0

In our application, we use document.forms[0] to access the form from JavaScript. This used to work fine, till we had to introduce another form before the current form (in the page header). Obviously, now none of our form submits will work properly as it will pick up the form specified in the header.

Is there anyway, we can have document.forms[0] to reference the existing form.

The only other option we have is to reference both the forms by name and use the name in the JavaScript. But since this constitutes a considerable amount of rework, I was just thinking if the community could throw up an alternative solution.

To clarify: Using document.getElementById would be the better solution, but that is something that is planned for next major version. We would be very much stressed to have that added in the current release cycle.

  • 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-25T09:52:57+00:00Added an answer on May 25, 2026 at 9:52 am

    You could put the form that’s at the top of the page at the bottom of the HTML, and use some fancy CSS to make it show up at the top of the page. Alternatively, you may be able to use some Javascript to define the form at the top of the page after the page loads, which (i think) would make the original form show up as form[0], and the top form show up as form[1]. Even something like a simple TopFormDiv.innerHTML = ‘all your form html goes here’ in the body.onload might be sufficifient, of course, you can make this much more complicated.

    Additionaly, you could consider “monkey patching” the document.Forms object so that the document.Forms[0] returns the form you want it to. What I’m thinking is have some code at the top of your page which switches out document.Forms[0] to the one you want it to represent, and moves everything else over 1 position. This would have to be done after the document is done loading, but before anything else on the page tries to access the form.

    UPDATE

    After some initial testing, it appears that calling document.forms[0] actually searches through current DOM until it returns the first form. So even if you define the form later, after the page loads, as I recommended in the first paragraph, it doesn’t seem to work as you would expect. Even the “monkey patching” doesn’t work as setting the value of forms[0] to some other form doesn’t seem to accomplish anything as forms[0] always returns the first form in the DOM tree. So, the only way I could see accomplishing this is to define the “top” form at the bottom of your HTML, and use CSS to position it at the top of the document. For a basic example of how to position the bottom form at the top of the page see this example

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

Sidebar

Related Questions

We are looking to use the MVC Framework in our SP Application. This is
We just moved our application from a MDI container to a single document interface.
Have Log4Net configured in our application to use a date stamped name and a
We're planning to use standard ASP.NET user authentication for our application. However, by default
We have started to use spring aop for cross cutting aspects of our application
We decided to use the minimumRequiredVersion in our clickOnce application manifest, and now when
I'm auditing our existing web application, which makes heavy use of HTML frames .
Friends, In testing our Oracle Forms application on Vista I have found a interesting
Our application requires a user to select a photograph from their camera. The cameras
I am new in asp.net,I have to luanch our application use asp.net,and I use

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.