title: Uncaught TypeError: Cannot set property 'action' of undefined
body: <p>I could not able to submit the form through javascript function. I have a requirement when user clicks on a link, i need to submit a form. Below is the error seen on browser console:</p>
  
  <pre><code>Uncaught TypeError: Cannot set property 'action' of undefined
  </code></pre>
  
  <p>Please suggest how can i submit the form to invoke the spring controller method.</p>
  
  <p>Below is the javascript function:</p>
  
  <pre><code>function submitDataOnClick(){
      document.myForm.action = contextPath + "/dataProcess.htm";
      document.myForm.submit();
  }
  &lt;body&gt;
  &lt;form name="myForm"&gt;
  //all form elements..
  &lt;table class="myClass"&gt;
       &lt;tr&gt;&lt;td&gt;&lt;a href="" onclick="submitDataOnClick()"&gt; &lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Spring controller:</p>
  
  <pre><code>    @RequestMapping(value = "/dataProcess", method = RequestMethod.GET)
      public ModelAndView dataProcess(HttpServletRequest request,
              HttpServletResponse response,
              BindingResult beException)
              throws IOException {
  
  //logic...
      ModelAndView mav = new ModelAndView();
      mav.setViewName("home");
      return mav;
  }
  </code></pre>