我如何在引导模式中回显我的结果而不会自动重新加载页面

时间:2019-07-02 16:57:44

标签: php bootstrap-4

我想在不重新加载页面或刷新页面的情况下在引导程序模式类中回显我的结果,但是每次我单击提交按钮时,它都会重新加载并逃脱模式类...我正在使用foreach循环,并且每次都在猜测循环在第一次之后计数,它清除了所有内容...

<?php 
$count_main_odd = 0;
$main_odds_error = $main_odds = "";
if(isset($_POST["submit"])){
    if(empty($_POST["total_odds"])){
    echo $main_odds_error = "<div class='error-msg'>You have not selected any odds</div>";
    }else{
    $main_odds      = $_POST["total_odds"];
    $total = 1;
    if(!empty($main_odds)){

        echo "You have selected the following games ";
        foreach ($main_odds as $final_odd){
            echo $final_odd;
                $total   = $total * $final_odd;
                $total1  = $final_odd . ", ";
        }
    }
    $count_main_odd = count($main_odds);
    echo number_format($total, 2);  
}
}
// calculating selected games
?>

这是页面上的“提交”按钮

<input type="submit" name="submit" value="Calculate Selected odds" class="btn btn-outline-success btn-sm card-link" data-toggle="modal" data-target="#exampleModalOdds"/>

这是模态类,我不得不删除代码,因为它看起来不整洁

<!-- Modal -->
<div class="modal fade" id="exampleModalOdds" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

点击提交按钮后,如何重新加载页面...

这是输入类型

<input type="checkbox" name="total_odds[]"  value="<?= $game->odds; ?>-<?= $game->home; ?>-<?= $game->away; ?>"/>

0 个答案:

没有答案