2016-05-30 20 views
0

我使用內置在窗體中的Kentico 8。Kentico 8 Form Autosum字段

我有我要總結創建總計

如各種費用領域。 $$input:cateringTotalCost$$ + $$input:venueHireTotalCost$$ = grand total

我到目前爲止有:被autosummed對於其他輸入字段

我能做到這一點,我怎麼totalExpenditure $$領域:

<td> align="right">$$input:trafficManagementTotalCost$$</td> 
</tr> 
<tr> 
    <th scope="row" style="text-align: left;">First aid</th> 
    <td> $$input:firstaidDetails$$</td> 
    <td> $$input:firstaidTotalCost$$</td> 
    <td>$$input:totalExpenditure$$</td> 

與$$輸入?

謝謝

+2

你真的嘗試過嗎?你有沒有得到任何錯誤? –

+0

我沒有嘗試,因爲我不知道如何。我找不到將它添加到gui表單構建器的地方,我不知道如何將它添加到html代碼中。我使用表單生成器來創建字段,然後將它們插入到Dreamweaver中,以便我可以自定義表單的佈局。我的形式的代碼是: –

+0

​​ALIGN = 「右」> $$輸入:trafficManagementTotalCost $$ \t \t \t \t \t 急救 \t \t​​$$輸入:firstaidDetails $$ \t \t​​$$輸入:firstaidTotalCost $$ ​​$$輸入:$ totalExpenditure $ $$ input:totalExpenditure $$字段正在爲其他輸入字段自動存儲。 –

回答

1

您可以使用JavaScript來創建autosum功能。一個獨特的識別器添加到與輸入字段的每個單元格,並附加與JS代碼類似的腳本標籤:

<table> 
... 
<tr> 
    <td id="cateringCell">$$input:cateringTotalCost$$</td> 
    <td id="venueHireCell">$$input:venueHireTotalCost$$</td> 
    <td id="totalCell">$$input:grandTotal$$</td> 
</tr> 
... 
</table> 

<script type="text/javascript"> 
$(document).ready(function() { 
    var cateringInp = $('#cateringCell').find('input'); 
    var venueHireInp = $('#venueHireCell').find('input'); 
    var totalInp = $('#totalCell').find('input'); 

    var autoSumFunc = function() { 
     //Plus add a code to test null/empty values 
     totalInp.val(cateringInp.val() + venueHireInp.val());   
    }; 

    cateringInp.change(autoSumFunc); 
    venueHireInp.change(autoSumFunc); 

    autoSumFunc(); 
}); 
</script> 

它假定你有包括:-) jQuery庫。

+0

太棒了!我明白你在說什麼,應該試試看。 非常感謝! –