2012-02-03 3 views
-4

を動作していないこれは、コードJavascriptのdocument.form.submit()

<?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> 

は今、私の質問は、このフォームが動作して取得する方法document.getElementById('sub').submit();

が動作していないということですか?

+3

すべてのコードを投稿することはあまり役に立ちません。小さなケースを分離し、問題のあると思われるコードのみを投稿してください。 – Ktash

+1

具体的にどのように機能していないか教えてください。 – ggreiner

+0

エラー:document.getElementById( "sub")。submitは関数ではありません ソースファイル:http://localhost/Tulip2011/associate_edit.php?associate = admin# 行:14 –

答えて

2

#subは送信ボタンです。あなたはそう、フォームを送信したい:

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

また、それは、それは「フォーム」プロパティを持つ必要がありますので、あなたが行うことができますフォームの一部であるため、:あなたがいる

document.getElementById("sub").form.submit(); 
0

フォームを送信しようとしているボタンを送信しようとしています。

または、JSを使用して送信ボタンをクリックします。

だから、どちらか:あなたは、フォーム要素ではなく、ボタン要素を提出

document.getElementById('sub').click(); 
+0

今から私の質問をもう一度質問することは許可されていないので、私の質問upvote pls pls pls –

+0

正当な理由ではありません。あなたの質問が良い場合、私はそれをupvoteだろう... – PeeHaa

0

ページ、cCheckに2つの形式がありますこれが動作している場合

document.forms [0] .submit();

又は

document.forms [1] .submit()。

関連する問題