我正在尝试制作“我应该参加这个测试还是那个测试”计算器。当我同时输入两个值时,什么也不会输出,所以我正在寻找代码中的错误。谢谢!
SELECT
* FROM
`table1`,
`table2`,
`table3`,
`table4`,...
`table12`,
WHERE
(
(
`table1`.`columnlast` LIKE '%string%'
) OR(
`table2`.`columnlast' LIKE '%string%'
) OR(
`table3`.`columnlast` LIKE '%string%'
)...
) OR(
`table12`.`columnlast` LIKE '%string%'
)
document.getElementById("test2score").onkeyup = function() {
WhichTestFunction()
};
function WhichTestFunction() {
var t1 = document.getElementById('test1score').value;
var t2 = document.getElementById('test2score').value;
if (t1 == 9) && (t2 < 120) {
score = "Take Test 1";
}
else if (t1 == 9) && (t2 > 140) {
score = "Take Test 2";
}
else if (act == 9) && (sat >= 120) && (sat <= 140) {
score = "Toss up. Take the test you like better based on format and content.";
}
document.getElementById("testscore").innerHTML = score;
}
答案 0 :(得分:1)
首先,您需要使用外部括号将if
语句包装起来
if ((act == 9) && (sat >= 120) && (sat <= 140)) {...}
然后您有几个未声明的变量导致异常
var score, sat, act;
注释1a:我不知道这3个变量是否应该全局声明/可用。
注释1b:由于不知道它们的实际含义,因此我注释掉了最后一个if
语句,因此该代码将在此演示示例中运行。
堆栈片段
<section id="" class="">
<div class="container text-center">
<div class="col-md-6 col-md-offset-1">
<h2><b>Which Test To Take?</b></h2>
<div class="col-md-4 col-md-offset-1">
<h6><b>Input Test 1 Score</b></h6>
<input type="number" id="test1score">
</div>
<div class="col-md-4 col-md-offset-1">
<h6><b>Input Test 2 Score</b></h6>
<input type="number" id="test2score">
</div>
<p id="testscore"></p>
</div>
</div>
</section>
<script>
document.getElementById("test2score").onkeyup = function() {WhichTestFunction()};
var score, sat, act;
function WhichTestFunction() {
var t1 = document.getElementById('test1score').value;
var t2 = document.getElementById('test2score').value;
if ((t1 == 9) && (t2 < 120)) {
score = "Take Test 1";
}
else if ((t1 == 9) && (t2 > 140)) {
score = "Take Test 2";
}
/*
else if ((act == 9) && (sat >= 120) && (sat <= 140)) {
score = "Toss up. Take the test you like better based on format and content.";
}
*/
document.getElementById("testscore").innerHTML = score;
}
</script>