Widget:Unitconversion2: verschil tussen versies
Uit wikilab
Regel 8: | Regel 8: | ||
var conv=parseFloat(c); | var conv=parseFloat(c); | ||
var resconv= 0; | var resconv= 0; | ||
− | var | + | var dec2=Math.pow(10,parseFloat(d)); |
if (!isNaN(unita) ) { | if (!isNaN(unita) ) { | ||
unitb=unita * conv; | unitb=unita * conv; | ||
Regel 15: | Regel 15: | ||
unita=unitb / conv; | unita=unitb / conv; | ||
} | } | ||
− | result=Math.round(unita * | + | result=Math.round(unita * dec2) / dec2; |
document.formulaForm.unit21.value=result; | document.formulaForm.unit21.value=result; | ||
− | result=Math.round(unitb * | + | result=Math.round(unitb * dec2) / dec2; |
document.formulaForm.unit22.value=result; | document.formulaForm.unit22.value=result; | ||
} | } | ||
Regel 34: | Regel 34: | ||
<td> x </td> | <td> x </td> | ||
− | <td rowspan="2"><input type="text" size="6" name=" | + | <td rowspan="2"><input type="text" size="6" name="conv2" value="<!--{$conv2|escape:'quotes'}-->" readonly></td> |
<td> = </td> | <td> = </td> | ||
Regel 42: | Regel 42: | ||
<td rowspan="2"><!--{$unit22|escape:'quotes'}--></td> | <td rowspan="2"><!--{$unit22|escape:'quotes'}--></td> | ||
− | <td rowspan="2" align="center"><input type="button" name="Calculate" value="Calc" onclick="calculateFormula2(document.formulaForm.unit21.value,document.formulaForm.unit22.value,document.formulaForm. | + | <td rowspan="2" align="center"><input type="button" name="Calculate" value="Calc" onclick="calculateFormula2(document.formulaForm.unit21.value,document.formulaForm.unit22.value,document.formulaForm.conv2.value,<!--{$dec2|escape:'quotes'}-->)"></td> |
<td rowspan="2" align="center"><input type="reset" name="resetButton" value="Reset"></td> | <td rowspan="2" align="center"><input type="reset" name="resetButton" value="Reset"></td> |