+
1
|
list
|
skin
|
login
|
editor
α-wwwiki
::
worksheet
user:none
(3196 bytes)
_h1 worksheet | [[worksheet3]] _p This is a first study. The goal is to create a true worksheet where cells can be linked, for example like this : {pre °° let cell A1 contains "123" and cell B2 contains "456" then, writing in C3 "{+ A1 B2}" will display "579" and more other functions like "{sum A1:A10}", ... °°} {table {@ style="width:100%; background:#ffe; text-align:right; font-family:courier;"} {tr {@ style="text-align:center; font-weight:bold; background:#ccc;"} {td } {td A} {td B} {td C} {td D} } {tr {td {@ style="font-weight:bold; background:#ccc;"} 1} {td article} {td quantity} {td price €} {td quant*price} } {tr {td {@ style="font-weight:bold; background:#ccc; width:10px;"} 2} {td {input {@ type="text" style="width:170px;" id="A2" value="fir tree wooden rod 3/3"}}} {td {input {@ type="text" style="width:100px; text-align:right;" id="B2" value="22.22"}}} {td {input {@ type="text" style="width:100px; text-align:right;" id="C2" value="23.23"}}} {td {@ id="D2" style="width:50px;"}} } {tr {td {@ style="font-weight:bold; background:#ccc; width:10px;"} 2} {td {input {@ type="text" style="width:170px;" id="A3" value="oak wooden floor 1"}}} {td {input {@ type="text" style="width:100px; text-align:right;" id="B3" value="32.32"}}} {td {input {@ type="text" style="width:100px; text-align:right;" id="C3" value="33.33"}}} {td {@ id="D3" style="width:50px;"}} } {tr {td {@ style="text-align:center;font-weight:bold;background:#ccc;"}4} {td} {td} {td {b total}} {td {@ id="D4"} } } } °°° end table °°° decimals : {input {@ type="text" style="width:10px;" id="decimals" value="3"}} {input {@ type="submit" value="compute" onclick="°° // a useful function : function decround (x,d) { var powd = Math.pow(10,d); return Math.round(x*powd)/powd; } // 1) input values : var A2 = getId('A2').value; var B2 = getId('B2').value; var C2 = getId('C2').value; var A3 = getId('A3').value; var B3 = getId('B3').value; var C3 = getId('C3').value; var dec = getId('decimals').value; // 2) define relations between cells var D2 = B2 * C2; var D3 = B3 * C3; var D4 = D2 + D3; // 3) display output getId('D2').innerHTML = decround( D2, dec ); getId('D3').innerHTML = decround( D3, dec ); getId('D4').innerHTML = decround( D4, dec ); °°"}} _h3 code {pre °° {input {@ type="submit" value="compute" onclick="•• // a useful function : function decround (x,d) { var powd = Math.pow(10,d); return Math.round(x*powd)/powd; } // 1) input values : var A2 = getId('A2').value; var B2 = getId('B2').value; var C2 = getId('C2').value; var A3 = getId('A3').value; var B3 = getId('B3').value; var C3 = getId('C3').value; // 2) define relations between cells var D2 = B2 * C2; var D3 = B3 * C3; var D4 = D2 + D3; // 3) display output getId('D2').innerHTML = decround( D2, 2 ); getId('D3').innerHTML = decround( D3, 2 ); getId('D4').innerHTML = decround( D4, 2 ); ••"}} °°}