从输入字段中的方程式
问题出现的原因是在obtainScoreOne函数中,使用了document.querySelector来获取输入框的值,但是在输入框的HTML代码中,没有为obtainScoreOne函数传递参数。这导致在调用obtainScoreOne函数时,无法获取输入框的值,从而无法进行计算。
要解决这个问题,需要修改HTML代码,在调用obtainScoreOne函数时,传递输入框的值作为参数。可以通过在onkeyup事件中调用obtainScoreOne函数,同时传递输入框的值作为参数来实现。修改后的HTML代码如下:
<input id="roundOne" onkeyup="obtainScoreOne(this.value, document.querySelector('#roundTwo').value, document.querySelector('#roundThree').value)" type="number" value="0"> <input id="roundTwo" onkeyup="obtainScoreOne(document.querySelector('#roundOne').value, this.value, document.querySelector('#roundThree').value)" type="number" value="0"> <input id="roundThree" onkeyup="obtainScoreOne(document.querySelector('#roundOne').value, document.querySelector('#roundTwo').value, this.value)" type="number" value="0">
通过修改HTML代码,将输入框的值传递给obtainScoreOne函数后,即可正常获取输入框的值并进行计算。这样,问题就得到了解决。