dre26973 2016-04-14 08:04
浏览 120

我无法从网页上的隐藏框中获取数据

I want the hidden box to display when the user clicks on other. And i want to get the interest rate from the text box and perform calculations like the other interest rates given. Any ideas? here is my code. Thanks

<html>
    <head>
        <meta charset="UTF-8">
        <title>Mortgage Calculator</title>
          <link rel="stylesheet" type="text/css" href="main.css" />

    </head>
    <body>

    <main>

        <h1>
          Mortgage Calculator  
        </h1>


  <script language="JavaScript" type="text/javascript">
<!--
function getOther(sel,fld){
    fld.style.display = (sel.selectedIndex===sel.options.length-1)?"inline":"none";
}
window.onload = function() {
    document.getElementById("Other").style.display = "none";
    document.getElementById("othLabel").style.display = "none";
}
//-->
</script>


<form action="Display.php" method = "POST">
  Price Of Home: <input type="text" name="PriceOfHome"><br></br>
  Down Payment: <input type="text" name="DownPayment"><br>

  <p> Duration Of Loan</p>
<input type="radio" name="DurationOfLoan" value="10 years"> 10 Years<br>
<input type="radio" name="DurationOfLoan" value="20 years"> 20 Years <br>
<input type="radio" name="DurationOfLoan" value="30 years"checked> 30 Years </br>


<br>
 <label for="Interest Rate">Interest Rate:</label>
<select name="InterestRate" onchange="getOther(this.form.Other);">

 <option value="4">4%</option>
 <option value="4.75">4.75%</option>
 <option value="5">5%</option>
 <option value="9">9%</option>
  <option value="10">10%</option>
 <option value="Other">Other</option>

 <option value="InterestRate" selected>4.5%</option>


 <input type="hidden" name="Other" value="<?php echo $var;?>" />
</select> 
 <label id="Other" for="Other">Other:</label><input type="text" name="Other" id="Other" style='display:none;'/>
 </br>

 <br></br>
 <button type="submit" value="Calculate">Calculate</button>
<button type="reset" value="Reset">Reset</button>

 <br></br>

</form>
        <?php
   //    $PriceOfHome = filter_input(INPUT_POST, 'PriceOfHome');
 //$DownPayment = filter_input(INPUT_POST, 'DownPayment');
// $action = filter_input(INPUT_POST, 'action');
          ?>
      </main>
    </body>

</html>


  <?php 

 //   $_POST['foo'];

 // get the data from the form
    $PriceOfHome = filter_input(INPUT_POST, 'PriceOfHome');
    $DownPayment = filter_input(INPUT_POST, 'DownPayment');
    $DurationOfLoan = filter_input(INPUT_POST, 'DurationOfLoan');
    // if ($DurationOfLoan == NULL) {
      //  $DurationOfLoan = 'invalid';
   // }

    $InterestRate = filter_input(INPUT_POST, 'InterestRate');
    $Other = filter_input(INPUT_POST, 'InterestRate');
    $TotalSimpleInterest = filter_input(INPUT_POST, 'Total Simple Interest');
    $TotalPriceOfHome = filter_input(INPUT_POST, 'Total Price Of Home');
    $MonthlyPayments = filter_input(INPUT_POST, 'Monthly Payments');



    // calculate the discount and discounted price
    //$InterestRate = ($InterestRate/100);
    $TotalSimpleInterest = $PriceOfHome - $DownPayment * ($InterestRate/100) *$DurationOfLoan;
    $TotalPriceOfHome = $PriceOfHome + $TotalSimpleInterest; 
    $MonthlyPayments =($TotalPriceOfHome/ $DurationOfLoan)/12;
   // $discount_price = $list_price - $discount;



 // apply currency formatting to the dollar and percent amounts
    $PriceOfHome = "$".number_format($PriceOfHome, 2);
    $DownPayment = "$".number_format($DownPayment, 2);
    $InterestRate = $InterestRate."%";
    $TotalSimpleInterest = "$".number_format( $TotalSimpleInterest, 2);
    $TotalPriceOfHome = "$".number_format( $TotalPriceOfHome, 2);
    $MonthlyPayments = "$".number_format( $MonthlyPayments, 2);






 ?>







<!DOCTYPE html>
<html>

<head>
    <title>Mortgage Calculator</title>
    <link rel="stylesheet" type="text/css" href="main.css">
</head>

<body>
    <main>
        <h1>Mortgage Calculator</h1>
        <br>  </br>
        <label>Price Of Home:</label>
        <span><?php echo ($PriceOfHome); ?></span>
        <br>  </br>

        <label>Down Payment:</label>
        <span><?php echo ($DownPayment); ?></span>
        <br>  </br>

        <label>Duration Of Loan:</label>
        <span><?php echo ($DurationOfLoan); ?></span>
          <br>  </br>

        <label>Interest Rate:</label>
        <span><?php echo ($InterestRate); ?></span>
         <br>  </br>

        <label>Total Simple Interest:</label>
        <span><?php echo ($TotalSimpleInterest); ?></span>
       <br>  </br>

        <label>Total Price Of Home:</label>
        <span><?php echo ($TotalPriceOfHome); ?></span>
       <br>  </br>

         <label>Monthly Payments:</label>
        <span><?php echo ($MonthlyPayments); ?></span>
       <br>  </br>

       <input type="hidden" name="Other" value="<?php echo $var;?>" />
    </main>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • dqydp44800 2016-04-14 08:07
    关注

    you can't receive a value from hidden input

    you can put the type of input = hidden

    <input type="hidden" name="Other" id="Other">
    

    or

    <input type="text" name="Other" id="Other" style='opacity:0;position:absolute;'>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)