-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex1.html
71 lines (65 loc) · 1.76 KB
/
ex1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<html>
<head>
<title>htmltmpl usage example</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="htmltmpl/core.js"></script>
<script type="text/javascript">
var tmpl; // make tmpl a global var for debug purposes
function add()
{
var el;
tmpl = new htmltmpl(document.getElementById("tbody_tmpl"),
{ ret_dom: 1 });
el = tmpl.apply({ id: document.getElementById("id").value,
name: document.getElementById("name").value,
fields: [ { title: "First parameter",
name: "prm1" },
{ is_exist: 1,
title: "Second parameter",
name: "prm2" } ] });
document.getElementById("cntr").appendChild(el);
}
</script>
</head>
<body>
<div id="tbody_tmpl" style="display: none">
<!--<tbody>
<tr>
<td>id:</td>
<td>{%TMPL_VAR NAME=id%}</td>
</tr>
<tr>
<td>name:</td>
<td>{%TMPL_VAR NAME=name%}</td>
</tr>
{%TMPL_LOOP NAME=fields%}
{%TMPL_IF NAME=is_exist%}
<tr>
<td>{%TMPL_VAR NAME=title%}</td>
<td><input type="text" name="{%TMPL_VAR NAME=name%}" value=""/></td>
</tr>
{%TMPL_ELSE%}
<tr>
<td cols="2">no title</td>
</tr>
{%/TMPL_IF%}
{%/TMPL_LOOP%}
</tbody>-->
</div>
<table>
<tbody>
<tr>
<td>id:</td>
<td><input type="text" id="id" value=""/></td>
</tr>
<tr>
<td>name:</td>
<td><input type="text" id="name" value=""/></td>
</tr>
</tbody>
</table>
<input type="button" onclick="add()" value="add"/>
<table id="cntr">
</table>
</body>
</html>