2017-04-06 133 views
1

我做了一个登录表单,我使用<button type="submit">但它不工作。当我使用<input type="submit">它完全工作...在Java中有任何方法脚本使用<button type="submit">提交表单?如何使用<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">它的工作原理,但是当我使用<button type="submit">我不工作,所以,我如何使用按钮来上班?

+2

*“我使用但它不工作,但当我使用它完全有效”* - 我想我只读了三次,我仍然不知道发生了什么。 – domsson

+0

无论如何,你知道有一个''是专门设计用来发送表单的吗? – domsson

+0

该代码最初是不可见的......现在它的确定 –

回答

0

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