计算输出不以模态显示

时间:2017-10-05 10:45:08

标签: javascript php modal-dialog

我的模态除标题外不显示输出(空模态)。当我不在模态中显示它时,我已经检查并且输出正在工作。

我可以更改什么来显示输出?

    <script> 
    $( function() {
      $( "#mortgageResults" ).dialog({
        autoOpen: false,
        modal: false,
        resizable: false,
        autoResize: true,
        show: {
          effect: "clip",
          duration: 400
        },
        hide: {
          effect: "drop",
          duration: 400
        }
      });

      $( "#mortgagebtn" ).on( "click", function() {
        $( "#mortgageResults" ).dialog( "open" );
        return false;
      });
    } );
    </script>

计算:

              <div id="calculator_one">
          <?php
      $borrow = $_POST['borrow']; //amount borrowed
      $interest = $_POST['interest']; //interest rate
      $term = $_POST['term']; //term
      $months = ( $term * 12 );
      $answer = ($borrow * ($interest / 100)) / 12;
      $answer_two = ( $borrow * (($interest/12) / 100) / ( 1 - pow( 1 + (($interest/12) / 100), -$months)) ); ?>
          <form id="calcualtor" action="" method="post" class="calculator">
            <label class="calcAmount">Amount to borrow &#40;&#8369;&#41;</label>
            <input class="calcAmount" type="text" name="borrow" maxlength="6" />
            <br />
            <label class="calcInterest">Interest &#40;&#37;&#41;</label>
            <input class="calcInterest" type="text" name="interest" maxlength="4" />
            <br />
            <label class="calcTerm">Term &#40;Years&#41;</label>
            <input class="calcTerm" type="text" name="term" maxlength="2" />
            <br />
            <button id="mortgagebtn" type="submit">Calculate</button>

          </form>
          </div>

我的显示输出:

      <div id="mortgageResults" title="Mortgage Results">
            <?php
      if (isset($_POST['mortgagebtn'])){
      echo "<p class='calc_header'>Results</p>";
      echo "<div id='results'><p class='calc_result'>Based on borrowing&nbsp;<span class='mortgage'>&#8369;", number_format($borrow) , "</span>&nbsp;over&nbsp;<span class='mortgage'>", ($term), "&nbsp;years</span>&nbsp;at&nbsp;<span class='mortgage'>", ($interest), "&#37;</span>, your monthly repayments would be&#58;</p>";
      echo "<p class='calc_result'>Interest Only&nbsp;<span class='mortgage'>&#8369;", number_format($answer,2), "</span></p>";
      echo "<p class='calc_result'>Repayment&nbsp;<span class='mortgage'>&#8369;", number_format($answer_two,2), "</span></p></div>";} ?>
          </div>

1 个答案:

答案 0 :(得分:0)

问题在于:

<button id="mortgagebtn" type="submit">Calculate</button>

这里你没有指定名字。而你正试图检查它:

if (isset($_POST['mortgagebtn'])){

指定名称:

<button id="mortgagebtn" name="mortgagebtn" type="submit">Calculate</button>

再试一次。