okey所以我得到了這個,有點看看它像你有一個網站是你可以兌換點,現在當我點擊贖回我不希望給出的數字小於4分和給出的數字大於你的平衡點數。Javascript如果功能不正常與getElemenById
現在,當我點擊按鈕,當輸入爲2,我將獲得2個警報(警報是用於測試)
但是,只要我按一下按鈕,當我把比我的資產負債較少的數量,我也會得到2個警報,說數字=(例如)7和平衡隱藏= 100.所以我不明白爲什麼我會得到這些警報。因爲它比平衡和大於4
也是這個領域的平衡得到存儲時refreshBalance()被調用較小:
<input type=hidden id="balancehidden" name="balancehide"
value=""/>
的Javascript:
<input type="text" id="number"><br>
<button type="button" class="btn btn-success" id="redeem">Redeem</button>
<body onload="refreshBalance()">
<script type="text/javascript">
document.getElementById('redeem').onclick = function() {
if(document.getElementById('number').value < 4 || document.getElementById('number').value > document.getElementById("balancehidden").value)
{
alert(document.getElementById("number").value);
alert(document.getElementById("balancehidden").value);
}
}
</script>
PLZ解釋爲什麼downvote? im new sry – Nick
爲什麼你的'input'和'button'標籤在體外?那些應該在你的身體內。 – litel
對不起忘了提及這是我的php文件snipet – Nick