2016-04-14 15 views
0

ユーザが他のアイテムをクリックしたときに隠しボックスを表示します。そして、私はテキストボックスから金利を取得し、与えられた他の金利のように計算を実行したいと思います。何か案は?ここに私のコードです。おかげウェブページの隠しボックスからデータを取得できません

<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> 
+0

あなたが特定の問題何ですかこれでどうですか?このコードを使用して取得したエラー(ある場合)を再現することは、私たちの仕事ではありません。 – TAM

答えて

0

あなたが入力の種類を置くことができる隠された入力

から値を受け取ることができない=隠さ

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

または

<input type="text" name="Other" id="Other" style='opacity:0;position:absolute;'> 
関連する問題