comparison demo/subforms.ur @ 780:0084af7af35a

subforms demo
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 May 2009 15:53:29 -0400
parents
children be0c4e2e488a
comparison
equal deleted inserted replaced
779:7394368a5cad 780:0084af7af35a
1 fun sub r =
2 let
3 fun sub' ls =
4 case ls of
5 [] => <xml/>
6 | r :: ls => <xml>
7 <li>{[r.Num]} = {[r.Text]}</li>
8 {sub' ls}
9 </xml>
10 in
11 return <xml><body>
12 {sub' r.Lines}
13 </body></xml>
14 end
15
16 fun subforms n =
17 if n <= 0 then
18 <xml/>
19 else
20 <xml>
21 <entry>
22 <hidden{#Num} value={show n}/>
23 <li>{[n]}: <textbox{#Text}/></li>
24 </entry>
25 {subforms (n - 1)}
26 </xml>
27
28 fun form n = return <xml><body>
29 <form>
30 <subforms{#Lines}>
31 {subforms n}
32 </subforms>
33 <submit action={sub}/>
34 </form>
35
36 <a link={form (n + 1)}>One more blank</a><br/>
37 {if n > 0 then
38 <xml><a link={form (n - 1)}>One fewer blank</a></xml>
39 else
40 <xml/>}
41 </body></xml>
42
43 fun main () = form 1