"ocaml_beginners"::[] Re: example for tables and forms with select/option

View: New views
2 Messages — Rating Filter:   Alert me  

"ocaml_beginners"::[] Re: example for tables and forms with select/option

by Dario Teixeira-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> I am looking for soem examples (Pleac-like examples, not
> "documentation") on using tables and forms with select
> option with Eliom (XHTML).

I'm attaching a simple example for select. I'll post an example
with tables momentarily.

Hope it helps!
Best regards,
Dario Teixeira



     

[Non-text portions of this message have been removed]


Re: "ocaml_beginners"::[] Re: example for tables and forms with select/option

by Dario Teixeira-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

> I'm attaching a simple example for select. I'll post an example
> with tables momentarily.

It seems the Ocaml_beginners group swallows attachments.  Here's
the select example, again:

Cheers,
Dario Teixeira

================================================================

open XHTML.M


let coucou_handler _ selection () =
        Lwt.return
                (html
                (head (title (pcdata "Results")) [])
                (body [p [ pcdata ("You sent: " ^ selection)]]))


let coucou_service =
        Eliom_predefmod.Xhtml.register_new_service
                ~path: ["coucou"]
                ~get_params: (Eliom_parameters.string "selection")
                coucou_handler


let coucou_form enter_selection =
        [
        fieldset
                [
                Eliom_predefmod.Xhtml.string_select ~name:enter_selection
                        (Eliom_predefmod.Xhtml.Option ([], "one", Some (pcdata "um"), false))
                        [
                        Eliom_predefmod.Xhtml.Option ([], "two", Some (pcdata "dois"), false);
                        Eliom_predefmod.Xhtml.Option ([], "three", Some (pcdata "trĂªs"), false);
                        ];
                Eliom_predefmod.Xhtml.string_input ~input_type:`Submit ~value:"Send" ()
                ]
        ]


let main_handler sp () () =
        let myform = Eliom_predefmod.Xhtml.get_form coucou_service sp coucou_form in
        Lwt.return
                (html
                (head (title (pcdata "")) [])
                (body [p [pcdata "Form for coucou:"]; myform]))


let main_service =
        Eliom_predefmod.Xhtml.register_new_service
                ~path: [""]
                ~get_params: Eliom_parameters.unit
                main_handler