view demo/subforms.ur @ 1035:f87d0fedc54c

Fix for lack of 'apply' method of IE6 native functions
author Adam Chlipala <adamc@hcoop.net>
date Sat, 21 Nov 2009 13:08:01 -0500
parents 0084af7af35a
children be0c4e2e488a
line wrap: on
line source
fun sub r =
    let
        fun sub' ls =
            case ls of
                [] => <xml/>
              | r :: ls => <xml>
                <li>{[r.Num]} = {[r.Text]}</li>
                {sub' ls}
              </xml>
    in
        return <xml><body>
          {sub' r.Lines}
        </body></xml>
    end

fun subforms n =
    if n <= 0 then
        <xml/>
    else
        <xml>
          <entry>
            <hidden{#Num} value={show n}/>
            <li>{[n]}: <textbox{#Text}/></li>
          </entry>
          {subforms (n - 1)}
        </xml>

fun form n = return <xml><body>
  <form>
    <subforms{#Lines}>
      {subforms n}
    </subforms>
    <submit action={sub}/>
  </form>

  <a link={form (n + 1)}>One more blank</a><br/>
  {if n > 0 then
       <xml><a link={form (n - 1)}>One fewer blank</a></xml>
   else
       <xml/>}
</body></xml>

fun main () = form 1