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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:36:18+00:00 2026-06-12T00:36:18+00:00

Bellow is my code snippet that present the problem what I’m facing with: <!–

  • 0

Bellow is my code snippet that present the problem what I’m facing with:

<!-- in a div -->
<a href="#" onclick="submit('/netnfork/site/billing/billing_plan_type', document.getElementById('dataForm'));" title="${addPlan}">
    <img src="/path/to/button" height="18" width="25" class="add_button"/>
</a>

<!-- bellow this, in another div -->
<form id="dataForm" action="/a/path" method="post">     
    <input type="hidden" name="page_number" id="pageNumber" value="//some JSP code"/>     
    <input type="hidden" name="row_id" id="rowId" />        
</form>

the submit function is declared in another file that is included in the beginning of this html file.

The problem is, that when I click on the link, I get this error: Uncaught TypeError: Cannot set property 'action' of null. Trying to alert the second parameter of submit function, I get null.

function submit(url, form) {
    alert(form);
    form.action = url;
    form.submit();  
}

I have an exact similar page in the same application that is working good. Can anyone explain me why I get this behavior?

I ran this page in Chrome and Mozilla, but the error occurs in both of them.

  • 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-06-12T00:36:19+00:00Added an answer on June 12, 2026 at 12:36 am

    Your problem is that this (specifically getElementById):

    submit('/netnfork/site/billing/billing_plan_type', document.getElementById('dataForm'));
    

    gets evaluated before the form actually exists in the DOM, to fix the problem you will need to change it to the following:

    function submit(url, formName) {
        var form = document.getElementById(formName);
        form.action = url;
        form.submit();
    }
    

    and in your HTML:

    submit('/netnfork/site/billing/billing_plan_type', 'dataForm');
    

    Alternatively you should use event listeners to handle this sort of functionality

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

Sidebar

Related Questions

Below is a snippet of code that is trying to post to a PHP
I would like to hear opinions on below code snippet. Is there anything that
Below is a code snippet that is creating object. Form userexit_save_document_prepare. data: /bks/exitmanager type
I'd like to write a code snippet that would grab all of the text
I'm am having a heck of a time finding a code snippet that works
I'm trying to write a vs code snippet that will take the selected and
Below is a code snippet that asks for user input, and if the input
I have the following code snippet that builds chained select boxes based on data
Below is a simple code snippet that demonstrates the seemingly buggy behavior of end
Which code snippet will give better performance? The below code segments were written in

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.