我有一些代码,我用来从两个输入生成计算,但我无法生成我需要的结果。
我有两个输入(让我们称之为input1和输入2)。 输入值时,它会根据以下内容计算:
(input1 x 0.156 $)x((输入2 x 15秒)x 4.2)x 12个月
我原来的代码如下:
var calculation = function() { var input1 = document.getElementById('people').value; var input2 = document.getElementById('stories').value; var result = Math.floor(input1 * 0.2 * input2 * 30); document.getElementById('result').innerHTML = result; return false; }这是变化的结果,我很难改变(上面的代码用于不同的计算)。 任何帮助将不胜感激!
I have some code that I was using to generate a calculation from two inputs but am having trouble generating the result I need.
I have two inputs (let's call them input1 and input 2). When you enter in a value, it calculates it based on the following:
(input1 x 0.156$) x ( (input2 x 15 seconds) x 4.2) x 12 months
My original code is as follows:
var calculation = function() { var input1 = document.getElementById('people').value; var input2 = document.getElementById('stories').value; var result = Math.floor(input1 * 0.2 * input2 * 30); document.getElementById('result').innerHTML = result; return false; }It's the var result that I'm having difficulty changing (the code above was for a different calculation). Any help would be greatly appreciated!
最满意答案
在我看来,您没有正确实施您的公式,请尝试将其更改为:
var result = Math.floor((input1 * 0.156) * ((input2 * 15)*4.2)*12);告诉我们4.2代表什么也是很好的。
这是一个有效的JSFiddle
It looks to me that you are not implementing your formula correctly, try changing it to:
var result = Math.floor((input1 * 0.156) * ((input2 * 15)*4.2)*12);It also will be good to tell us what 4.2 stands for.
Here's a working JSFiddle
更多推荐
发布评论