如何使用<button type =“submit”>标签提交表单

时间:2017-04-06 22:33:17

标签: javascript php

我创建了一个登录表单,我使用<button type="submit">但它不起作用。当我使用<input type="submit">时,它完全有效...在java脚本中是否有任何方法可以使用{{1提交表单?

<button type="submit">

这里当我使用 <form class="modal-content animate" method="post"> <div class="imgcontainer"> <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span> </div> <div class="container"> <label><b>Program name</b></label> <input type="text" placeholder="Enter Program name" name="Pname" required> <label><b>Authentication ID</b></label> <input type="password" placeholder="Enter Authentication ID" name="psw" required> <button type="submit" name="submit">Login</button> <input type="checkbox" checked="checked"> Remember me </div> <?php error_reporting(0); session_start(); include("connection.php"); $Pname=$_POST['Pname']; $psw=$_POST['psw']; $_SESSION['$Pname']=$Pname; if($_POST['submit']) { if($Pname=="" or $psw=="") { //echo '<p align="center" style="color:red">plz enter all info</p>'; } else { $sql="select * from login where psw='$psw'"; $rData=mysql_query($sql); $res=mysql_fetch_array($rData); if($res['Pname']==$Pname && $res['psw']==$psw) { header("location:po.php?psw=$psw"); } else { echo '<p align="center" style="color:red">invalid user name and password'; } } } ?> 时它可以正常工作,但是当我使用<input type="submit" name="submit">时我无法工作......那么我怎样才能使用按钮工作?

1 个答案:

答案 0 :(得分:0)

您可以通过在按钮的点击事件处理程序中调用表单上的.submit()来通过JavaScript提交表单。

相关问题