在VTL中有三種類型的references:變數(variables)、屬性(properties)、方法(methods)。
用$字元開始的references用於得到什麼;使用#字元開始的directives(指令)用於作些什麼。
第一:#foreach($zz in [1..$info.Rows.Count])
#set($zzz = $zz + 7)
<td id="changeTD$!{item.userId}$zzz" ondblclick="ChangeDropDown(this,'$zz','$item.get_Item($zzz)','$!{item.userid}');">
<span>$item.get_Item($zzz)</span>
</td>
此執行個體:動態行轉列的執行個體,注意1.id="changeTD$!{item.userId}$zzz避免重複id,2.賦值方式$item.get_Item($zzz)
第二:手動頁面載入給每一個input註冊驗證事件,
View Code
1 #foreach($item in $dt.Rows)
2 <tr>
3 <td width="170px">
4 <input id="inputID$!{velocityCount}" type="text" class="fenshu" name="inputScore$!{velocityCount}" value="" />
5
6 </td>
7
8 </tr>
9 <script>
10 $(document).ready(function () {
11 $("#inputID$!{velocityCount}").formValidator({ empty: true }).regexValidator({ regExp: "Score", dataType: "enum", onError: "分數:請輸入0--100之間的數!" });
12 });
13 </script>
14 #end
注意:$!{velocityCount}從1開始。
第三:view.aspx?userId=$!{item.userId}&fileNumber=$!{item.fileNumber} 傳參數時用一個&