2016-03-07 43 views
0

我试着在我点击提交按钮以确认其工作后回显JavaScript,但它只关闭模式并刷新页面。怎么了? 我也试过 “如果($ _ POST [projectSubmit”],而围绕它isset()函数,但它无法识别指数“projectSubmit”

<form action="" method="POST"> 
<div id="modal1" class="modal modal-fixed-footer" style="width:35%;"> 
    <div class="modal-content"> 
     <h4>Create Project</h4> 
<div class="row"> 

     <div class="input-field col s12"> 
      <i class="material-icons prefix">perm_identity</i> 
      <input type="text" name="projectName" class="validate"> 
      <label for="projectName" class="">Project Name</label> 
     </div> 

     <div class="input-field col s12"> 
      <i class="material-icons prefix">room</i> 
      <label for="projectLocation">Location</label> 
      <input type="text" name="projectLocation"> 
     </div> 

     <div class="input-field col s12"> 
      <label for="projectType">Project Type</label><br> 
      <input name="projectType" type="radio" value="Condominium" id="test1" /> 
      <label for="test1" class="black-text">Condominium</label> 

      <input name="projectType" type="radio" value="Housing"  id="test2" /> 
      <label for="test2" class="black-text">Housing</label> 
     </div> 

</div><!--ROW--> 


    </div> 
    <div class="modal-footer"> 
     <input type="submit" name="projectSubmit"class="waves-effect waves-green btn-flat" value="s"> 
     <button type="RESET" class="btn btn-flat">RESET</button> 
    </div> 
    </div> 
    <?php 
if(isset($_POST['projectSubmit'])){ 
echo "<script type='text/javascript>alert('JUJU');</script>"; 

} 
else{ 
echo "<script type='text/javascript>alert('xx');</script>"; 
} 


?> 


</form> 

回答

4

您还没有完成文本之后的单引号/不支持JavaScript 请更新如下:

echo "<script type='text/javascript'>alert('JUJU');</script>"; 

和相同更新第二回声:

echo "<script type='text/javascript'>alert('xx');</script>"; 
+0

感谢您惊异的目光C:但是,当我点击提交,它不会回应警报?为什么?编号: NEVERMIND。它现在工作完美:D。 2分钟后我会标记你的帖子c:谢谢! – Jerlon

+0

谢谢;)我试过这段代码,它完全符合回应警报。 – RK12

1

INCOR矩形Java脚本标签(缺失报价)

您的代码

echo "<script type='text/javascript>alert('JUJU');</script>"; 

正确的标签

echo "<script type='text/javascript'>alert('JUJU');</script>"; 

为参考Can the <script> tag not be self closed?