comparison tests/tsource.ur @ 1463:607657eb2865

Properly handle form textboxes that have sources
author Adam Chlipala <adam@chlipala.net>
date Sun, 29 May 2011 12:44:31 -0400
parents
children
comparison
equal deleted inserted replaced
1462:c12ceb891350 1463:607657eb2865
1 fun doSubmit r =
2 return <xml>Done {[readError r.Amount1 * readError r.Amount2 * 2.0]}</xml>
3
4 fun main () =
5 amount1S <- source "1";
6 amount2S <- source "1";
7 return <xml> <body>
8 <form>
9 <table>
10 <tr><td>Amount1:</td><td><textbox{#Amount1}
11 source={amount1S}/></td></tr>
12 <tr><td>Amount2:</td><td><textbox{#Amount2}
13 source={amount2S}/></td></tr>
14 <tr><td>Total:</td><td><dyn signal={showTotal amount1S
15 amount2S}/></td></tr>
16 </table>
17 <submit value="Buy" action={doSubmit}/>
18 </form>
19 </body>
20 </xml>
21
22 and showTotal amount1S amount2S =
23 a1 <- signal amount1S;
24 a2 <- signal amount2S;
25 return (case ((read a1), (read a2)) of
26 (None, _) => <xml></xml>
27 | (_, None) => <xml></xml>
28 | (Some a, Some b) => <xml>{[a * b * 2.0]}</xml>)