2016-09-18 60 views
-2

嘿,我想通過輸入$量你得到我有多少的捐贈地位 天,如下所示 https://www.sixth-sen.se/index.php?/donate/ 試過多種方法和代碼,但都不知道我怎麼能做出這樣的計算器 他們工作捐贈天計算器問題

+1

查看頁面源 – mlegg

+0

嘗試幾個小時,好像他們已經在某種程度上保護它,它不工作 –

+0

什麼?你有沒有右鍵點擊頁面本身並選擇查看源代碼?它就在那裏。 view-source:https://www.sixth-sen.se/index.php?/ donate/ – mlegg

回答

0

不要使用<center>,它是舊的和不推薦使用。相反,使用CSS:

$(document).ready(function() { 
 
    var promotion = 3; 
 

 
    $("#donations").keyup(function() { 
 
    var amount = $("#donations").val(); 
 
    if (amount == "") { 
 
     $("#donation_amout").html("<h3>You have not entered any amount.</h3>"); 
 
     document.getElementById('amount').value = amount; 
 
    } else if (amount < 0.50) { 
 
     $("#donation_amout").html("<h3>Not acceptable, must be higher than $0.50!</h3>"); 
 
     document.getElementById('amount').value = amount; 
 
    } else if (amount < 1) { 
 
     var count = amount * promotion; 
 
     $("#donation_amout").html("<h3>Contributor Status for <b>0</b> days</h3>"); 
 
     document.getElementById('amount').value = amount; 
 
    } else if (amount >= 1 && amount < 100000000) { 
 
     var count = Math.floor(amount) * promotion; 
 
     $("#donation_amout").html("<h3>Contributor Status for <b>" + count + "</b> days</h3>"); 
 
     document.getElementById('amount').value = amount; 
 
    } else if (amount > 100000000) { 
 
     $("#donation_amout").html("<h3>The amount is out of range!</h3>"); 
 
     document.getElementById('amount').value = amount; 
 
    } 
 
    }); 
 
});
.amount { 
 
    margin: auto; 
 
    width: 20%; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="amount"> 
 
    <h2>Donation Amount</h2> 
 
    <b>$</b> 
 
    <input type="text" placeholder="Input the donation amount and discover what you'd get" id="donations" name="donation"> 
 
    <div id="donation_amout"></div> 
 
</div>