【发布时间】:2019-03-16 13:55:48
【问题描述】:
我是初学者,不知道为什么我的 if 语句不起作用。我正在使用 wixcode 和 javascript。下面的每个 if 语句都显示了我尝试运行计算的不同方式。作为 SR 输入的数字显示在 onClick 文本框中,但不运行计算来操作输入数字,或者它可能没有一起运行 if 语句。我错过了什么明显的东西吗?
$w.onReady(function () {
$w("#generatequote").onClick((event) => {
var SR = $w("#SR").value;
if (SR<100) {
$w("#SR").value = SR *2
//example one. Tried making it write the input * 2 if the input number is less than 100
}
else if (SR>=100&&SR<300) {
$w("#SR").value = ("#SR")*1.5;
//example two. Tried making it write the input * 1.5 if the input number is between 100 and 300
}
else if (SR>=300&&SR<600) {
$w("#SR").value * 1.25;
//example three. Tried making it write the input * 1.25 if the input is between 300 and 600
}
else if(SR>=600) {
$w("#SR").value = ("SR");
}
$w("#quotetext").value =(SR)
【问题讨论】:
-
它不运行任何语句吗?
onClick还能用吗? -
我希望您的代码末尾有匹配的 }),因为它没有在您的示例中显示
-
onClick 确实有效,但它不运行任何语句。我确实在代码末尾有 }),我只是忘记将它包含在示例中,因为它是在给我自己的一堆注释之后出现的。对此感到抱歉。
标签: javascript velo