用户对问题“显示结果未显示”的回答

您所在的位置:网站首页 你输入的字词未显示任何结果 用户对问题“显示结果未显示”的回答

用户对问题“显示结果未显示”的回答

#用户对问题“显示结果未显示”的回答| 来源: 网络整理| 查看: 265

主要的问题是,您需要在单击按钮时调用的函数中声明这些输入值。否则,它们都将被设置为它们加载的值(null)

我更改了你的一些代码,并添加了注释。希望这能有所帮助

Test Check Eligibility //const Income = parseInt(Amount.value); //const Years = parseInt(Duration.value); function eligibility(){ //You need the declare these values inside the function (getting them globally will only get the value they are when page loads up) let Amount = document.querySelector("#amount").value; let Duration = document.querySelector("#years").value; let amt = parseInt(Amount); let dura = parseInt(Duration); let Message = document.querySelector("#result"); if(amt < 50000){ Message.innerText = "Please! You're not eligible for the loan"; // console.log('Try again') } //Change this else-if to just an else since you are just checking for the exact opposite of your if statement else{ Message.innerText = "Please Fill the form below and apply" // console.log('Please Fill the form below and apply') } } //Prevent form from submitted or else page will reload and no message would be shown document.querySelector('form').addEventListener('submit', (e)=>{ e.preventDefault(); });



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3