I have an Excel file that shows a table where the user changes the value of a field. When this value changes the value of another field changes automatically because it has this formula:
row 26 =IF(DWT<40000,11500,(11500+(0.2*(DWT-40000)))).
I want to publish that Excel file on the web but don't lose its interactivity. Tried to save it as an HTML but no luck, no interactivity was saved, just a static HTML. I decided to build it using Notepad++ (HTML).
Now, I'm stuck at this point: I want the user to enter a value in "1", then press OK and the result appears in "2".
Here's the code I have written so far:
User enters a value in 1:
<td class=xl6612603>Dwt:</td>
<td class=xl6512603>
<form id="numform" oninput="x.value=parseInt(a.value)">
<input type="number" id="a" step="any" value="a<40000,11500,(11500+(0.2*(a-40000)))">
<input type="submit" value="OK">
<b>Enter value and press "OK"</b>
</form>
</td>
Result appears in 2:
<td rowspan=2 class=xl10112603 width=97 style='border-top:none;width:73pt'>
<output form="numform" name="x" for="a"></output>
</td>
Where a
is "DWT", as far as it concerns the math formula I wrote above.
The above code is giving me this: when user enters a value in "1" the same value appears in "2" automatically. I'm missing some things here...
Have attached an image Shows what I want to do
UPDATE: Problem solved but got stuck somewhere else.
So, I want user to enter a value in field number "4" and the result to appear in field "5" and field "6".
Field "5" has this formula: field "4" * 0.1
Field "6" has a different one: field "4" * 0.05
This is the code I wrote for the field "5" but it doesn't work though I put it inside the :
<body>
<script>
window.formula = function (val1) {
var b = parseInt(val1);
var c = 0.1;
var d = b * c;
return d;
}
</script>
This is the code I wrote for field "4":
<td class=xl6612603>Gross Tonnage:</td>
<td class=xl6512603><form id="numform" oninput="y.value=formula(b.value)"> <input type="number" id="b" step="any"><input type="submit" value="OK"><b> Enter value and press "OK"</b></form></td>
This is the code I wrote for field "5":
<td rowspan=2 class=xl10112603 width=97 style='border-top:none;width:73pt'><output form="numform" name="y" for="b"></td>
Here's another pic that shows what I want to do
答案 0 :(得分:0)
Javascript不了解Excel公式。
你需要转换
a<40000,11500,(11500+(0.2*(a-40000)))
等效的javascript
假设我理解了Excel公式,以下JSFiddle应该可以解决问题。