doushang2023 2012-02-03 19:14
浏览 182

Javascript document.form.submit()无法正常工作[关闭]

This is the code

<?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'];

               }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="calendar.css" rel="stylesheet" type="text/css"> 
<script language="JavaScript" src="ajax.js"></script>
 <script language="javascript">
 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();

}

}

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

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

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


</form></table>
  </p>
  <div id="edit">
</div>
</div></div>
      </div>

    </div>
    <div style="clear:both;">&nbsp;</div>
</div>
</div>

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

Now my question is that the document.getElementById('sub').submit(); is not working

How to get this form working?

  • 写回答

4条回答 默认 最新

  • douziqian2871 2012-02-03 19:18
    关注

    #sub is your submit button. You want to submit the form, so:

    document.getElementById("form1").submit();
    

    Also, since is it is part of a form, it should have a 'form' property, so you can do:

    document.getElementById("sub").form.submit();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序