Javascript document.form.submit() not working
<p>This is the code</p>

<pre><code>&lt;?php 
session_start();
require_once("config.php");
session_start();
require_once("checkuser.php");
checkuser();
       if(isset($_GET['associate']))
               {
$_SESSION['form']['code']=$_GET['associate'];

               }
               if(isset($_GET['branch']))
               {
$_SESSION['form']['br_code']=$_GET['branch'];

               }
?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;link href="calendar.css" rel="stylesheet" type="text/css"&gt; 
&lt;script language="JavaScript" src="ajax.js"&gt;&lt;/script&gt;
 &lt;script language="javascript"&gt;
 function open_window1()
 {
     window.open("help_associate_edit.php");
     }
    function open_window2()
 {
     document.form.action="br_code_edit.php";
     document.getElementById('sub').submit();

     }
     function check()
{

        if(document.frm.br_name.value=="")
        {
        alert("Please specify your branch name");
        document.frm.br_name.focus();
        }
        else if(document.frm.br_code.value=="")
        {
        alert("please specify Branch Code");
        document.frm.br_code.focus();
        }
        else if(document.frm.name.value=="")
        {
        alert("please specify your Name");
        document.frm.name.focus();
        }
        else if(document.frm.father_name.value=="")
        {
        alert("please specify your father's name ");
        document.frm.father_name.focus();
        }
        else if(document.frm.dob.value=="")
        {
        alert("Enter Date Of Birth");
        document.frm.dob.focus();
        }
        else if(document.frm.occupation.value=="")
        {
        alert("Enter occupation");
        document.frm.occupation.focus();
        }
        else if(document.frm.r_address.value=="")
        {
        alert("please specify your address ");
        document.frm.r_address.focus();
        }

        else if(document.frm.phone.value=="")
        {
        alert("please specify phone");
        document.frm.phone.focus();
        }

        else if(document.frm.document.value=="")
        {
        alert("please specify document");
        document.frm.document.focus();
        }else if(document.frm.intro_name.value=="")
        {
        alert("please specify introducer name");
        document.frm.intro_name.focus();
        }
        else if(document.frm.intro_code.value=="")
        {
        alert("please specify introducer code");
        document.frm.intro_code.focus();
        }
        else if(document.frm.t_name.value=="")
        {
        alert("please specify Top associate name");
        document.frm.intro_code.focus();
        }else if(document.frm.t_code.value=="")
        {
        alert("please specify top associate code");
        document.frm.t_code.focus();
        }
        else
        {
         document.frm.submit();
        }
}
 function calldel(a)

{

if (confirm("Are you sure you want to delete this?"))

{

    document.frm.method="post";

    document.frm.action="associate_edit_verify.php?del="+a;

    document.frm.submit();

}

}

&lt;/script&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Tulip Agritech India Limited&lt;/title&gt;
&lt;link href="style.css" rel="stylesheet" type="text/css" /&gt;
&lt;script language="JavaScript"&gt;
&lt;!--
function mmLoadMenus() {
  if (window.mm_menu_1215174111_0) return;
                                    window.mm_menu_1215174111_0 = new Menu("root",178,30,"Verdana, Arial, Helvetica, sans-serif",14,"#555152","#FFFFFF","#F3F3F3","#457FBE","left","middle",5,0,1000,-5,7,true,true,true,0,false,false);
  mm_menu_1215174111_0.addMenuItem("Ongoing&amp;nbsp;Projects","location='ongoing_projects.php'");
  mm_menu_1215174111_0.addMenuItem("Future&amp;nbsp;Plans","location='future_plans.html'");
   mm_menu_1215174111_0.hideOnMouseOut=true;
   mm_menu_1215174111_0.bgColor='#CDCDCD';
   mm_menu_1215174111_0.menuBorder=1;
   mm_menu_1215174111_0.menuLiteBgColor='';
   mm_menu_1215174111_0.menuBorderBgColor='#CDCDCD';

mm_menu_1215174111_0.writeMenus();
} // mmLoadMenus()
//--&gt;
&lt;/script&gt;
&lt;script language="JavaScript" src="mm_menu.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;? if(isset($_GET['associate']))
{?&gt;
&lt;body onload="call();"&gt;
&lt;? } else
{
    ?&gt;
    &lt;body&gt;
    &lt;? } ?&gt;
&lt;script language="JavaScript1.2"&gt;mmLoadMenus();&lt;/script&gt;
&lt;div id="wrapper"&gt;
  &lt;div id="header"&gt;
    &lt;div id="header_left"&gt;&lt;img src="images/company_logo.jpg" alt="company_logo" /&gt;&lt;/div&gt;
    &lt;div id="header_right"&gt;
      &lt;div id="login"&gt;&lt;a href="#"&gt;&lt;img src="images/login.jpg" alt="login" width="85" height="30" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="#"&gt;&lt;img src="images/register_now.jpg" alt="register_now" width="114" height="30" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;
      &lt;div id="search_box"&gt;
        &lt;form id="form1" name="form1" method="post" action=""&gt;
          &lt;table width="100%" border="0" cellspacing="0" cellpadding="0"&gt;
            &lt;tr&gt;
              &lt;td&gt;&lt;input name="textfield" type="text" class="search_field" value="KeyWords Here..." /&gt;&lt;/td&gt;
              &lt;td align="right" valign="middle"&gt;&lt;input type="image" name="imageField" src="images/go.jpg" /&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;div id="navigation"&gt;&lt;br /&gt;
  &lt;div id="nav"&gt;
      &lt;div id="nav_content"&gt;
        &lt;ul id="menu"&gt;
          &lt;li&gt;&lt;a href="index.php"&gt;HOME&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;img src="images/nav_div.jpg" alt="nav_div" /&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="about_us.html"&gt;ABOUT US&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;img src="images/nav_div.jpg" alt="nav_div" /&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="associate.html"&gt;ASSOCIATE&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;img src="images/nav_div.jpg" alt="nav_div" /&gt;&lt;/li&gt;
          &lt;li style="cursor:pointer;"&gt;&lt;a href="#" name="link3" id="link1" onmouseover="MM_showMenu(window.mm_menu_1215174111_0,0,34,null,'link3')" onmouseout="MM_startTimeout();" &gt;PLAN &amp; PROJECTS&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;img src="images/nav_div.jpg" alt="nav_div" /&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="contact_us.html"&gt;CONTACT US&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
      &lt;div id="social_network"&gt;&lt;a href="http://www.facebook.com/pages/Tulip-Agritech-India-limited/317573084925856"&gt;&lt;img src="images/facebook.jpg" alt="facebook" border="0" /&gt;&lt;/a&gt; &amp;nbsp;&lt;a href="https://twitter.com/#!/tulip_india"&gt;&lt;img src="images/twitter.jpg" alt="twitter" width="28" height="29" border="0" /&gt;&lt;/a&gt; &amp;nbsp;&lt;a href="#"&gt;&lt;img src="images/youtube.jpg" alt="youtube" width="28" height="29" border="0" /&gt;&lt;/a&gt; &amp;nbsp;&lt;a href="#"&gt;&lt;img src="images/space.jpg" alt="space" width="28" height="29" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;div id="inner_banner_bg"&gt;
  &lt;div id="inner_banner"&gt;&lt;img src="images/associate_banner.jpg" alt="associate" width="1000" height="108" /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="width:100%; margin-top:22px;"&gt;
  &lt;div id="body"&gt;
      &lt;div align="right"&gt;

&lt;a href="logout.php"&gt;&lt;img src="./image/logout.jpg"  style="width:25px"alt=""&gt;Logout&lt;/a&gt;
&lt;/div&gt;&lt;div  align="center"&gt;
  &lt;p&gt;  
    &lt;table width="662"&gt;&lt;th colspan="2"&gt;Registration Form (
* indicates the field is required)&lt;/th&gt;
&lt;/tr&gt;
&lt;form name="form"&gt;
&lt;tr&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td width="173"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td width="207"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td width="266"&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td height="74"&gt;&lt;div align="left"&gt;Associate code
&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="text" name="code" id="code" size="32" value="&lt;?=$_SESSION['form']['code']?&gt;"/&gt;&lt;/td&gt;
&lt;td width=""&gt;&lt;input type="button" name="sub" id="sub" value="Edit" size="32" onClick="call();" /&gt;&lt;a href="#" onClick="open_window1();"&gt;&lt;img src="image/help-icon.jpg" width="30" height="30"&gt;&lt;/a&gt;&lt;a href="associate_home.php"&gt;&lt;strong&gt;Back to menu&lt;/strong&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;


&lt;/form&gt;&lt;/table&gt;
  &lt;/p&gt;
  &lt;div id="edit"&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;
    &lt;div style="clear:both;"&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;div id="footer_bg"&gt;
  &lt;div id="footer"&gt;&lt;br /&gt;
      &lt;div class="footer_text" style="float:left;"&gt;&lt;a href="index.php"&gt;HOME&lt;/a&gt;&amp;nbsp;  |&amp;nbsp; &lt;a href="about_us.html"&gt;ABOUT US&lt;/a&gt;&amp;nbsp;  |&amp;nbsp; &lt;a href="#"&gt;ASSOCIATE&amp;nbsp;&lt;/a&gt; |  &amp;nbsp;&lt;a href="plan_projects.html"&gt;PLAN &amp;amp; PROJECTS&lt;/a&gt; &amp;nbsp;|&amp;nbsp; &lt;a href="contact_us.html"&gt;CONTACT US&lt;/a&gt;
          &lt;p&gt;CopyRight All Right Reserved &lt;a href="http://www.tulipindia.biz"&gt;&lt;span class="green_text1"&gt;tulipindia.biz&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
    &lt;div class="green_text1" style="float:right;"&gt;&lt;span class="black_text1"&gt;Address:&lt;/span&gt; &lt;span class="green_text3"&gt;Registered Office &lt;/span&gt;&lt;br /&gt;
          &lt;span class="black_text2"&gt;New Town, PO+PS: Diamond Harbour&lt;br /&gt;
            PIN: 743331, 24PARGANAS SOUTH, West Bengal&lt;/span&gt; &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Now my question is that the <code>document.getElementById('sub').submit();</code> is not working</p>

<p>How to get this form working?</p>
