在isset PHP

时间:2016-09-16 14:58:56

标签: javascript php jquery html

我正在尝试在表格中单击提交时打开模态。 我试图将动画更改为fadeIn,因为使用淡入淡出模式仅显示闪光。

当我使用fadeIn模式出现时的结果但是在瞬间出现并且我没有在整个页面中包含任何计时器或刷新。

我可以使用示例代码来显示模态并在

中设置条件
if(isset($_POST['pending']))     {  ...alert ..}

或者请对此提出意见。

因为我无法正确使用和查看模式。

注意:它有一个模态和jquery的引导程序,但我没有在帖子中包含这里

	while($record = mysql_fetch_array($myData))
{
  echo "<form action='dir_1.php' method='POST'>";
  echo "<tr>";
  echo '<td><input type="submit" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal" /></td>';
  echo "</tr>";
  echo "</form>";
}	    		

if(isset($_POST['pending'])){            
            
            echo('                
   <div class="modal fadeIn" id="myModal" role="dialog">
      <div class="modal-dialog">
    <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Modal Header</h4>
            </div>
            
            <div class="modal-body">
                <h2>Enter your First and Last Name</h2>
                    <form action="submit_prompt.php" method="post">
                            <p><strong>First Name:</strong><br /> 
                                <input type="text" name="notes" id="input1"/></p>
                                <input type="submit" name="submit" value="Add"  />
                    
            </div>
            
            <div class="modal-footer">
                 <input type="submit" name="submit" value="Add"  />
                <button type="button" onclick="play()" class="btn btn-default" data-dismiss="modal">Close</button>
                </form>
            </div>
            
        </div>
      </div>
    </div>
            ');
}

1 个答案:

答案 0 :(得分:0)

您是否尝试使用JavaScript触发:

<?php if(isset($_POST['pending'])) { ?>
<script>
$( document ).ready(function() {
    $('#myModal').modal('show')  
});
</script>
<?php } ?>

快速浏览器测试,testmodal.php:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

<div class="modal fadeIn" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
    </div>

    <div class="modal-body">
        <h2>Enter your First and Last Name</h2>
            <form action="submit_prompt.php" method="post">
                    <p><strong>First Name:</strong><br /> 
                        <input type="text" name="notes" id="input1"/></p>
                        <input type="submit" name="submit" value="Add"  />

    </div>

    <div class="modal-footer">
         <input type="submit" name="submit" value="Add"  />
        <button type="button" onclick="play()" class="btn btn-default" data-dismiss="modal">Close</button>
        </form>
    </div>

</div>
</div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<?php if(isset($_GET['pending'])) { ?>
<script>
$( document ).ready(function() {
    $('#myModal').modal('show')  
});
</script>
<?php } ?>

在浏览器中:

http://your-domain/testmodal.php?pending=fakevar