这是代码
<?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 Projects","location='ongoing_projects.php'");
mm_menu_1215174111_0.addMenuItem("Future 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> <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> <a href="https://twitter.com/#!/tulip_india"><img src="images/twitter.jpg" alt="twitter" width="28" height="29" border="0" /></a> <a href="#"><img src="images/youtube.jpg" alt="youtube" width="28" height="29" border="0" /></a> <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"> </td>
<td width="207"> </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;"> </div>
</div>
</div>
<div id="footer_bg">
<div id="footer"><br />
<div class="footer_text" style="float:left;"><a href="index.php">HOME</a> | <a href="about_us.html">ABOUT US</a> | <a href="#">ASSOCIATE </a> | <a href="plan_projects.html">PLAN & PROJECTS</a> | <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>
现在我的问题是document.getElementById('sub').submit();
无效
如何使此表单正常工作?
答案 0 :(得分:2)
#sub
是您的提交按钮。您想提交表单,所以:
document.getElementById("form1").submit();
另外,既然它是表单的一部分,它应该有一个'form'属性,所以你可以这样做:
document.getElementById("sub").form.submit();
答案 1 :(得分:0)
您正在尝试提交一个按钮,您应该尝试提交表单。
或者使用JS单击“提交”按钮。
所以:
document.getElementById('form1').submit();
或者:
document.getElementById('sub').click();
答案 2 :(得分:0)
您提交表单元素,而不是按钮元素。
为表单指定一个id - 例如“associateform”,然后将您的javascript更改为:
document.getElementById('associateform').submit();
另一种方法是: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml
答案 3 :(得分:0)
页面中有两种形式,请检查这是否有效
document.forms [0] .submit();
或
document.forms [1] .submit();