How to add a select (or other form element)?

In forms towards Eliom services:

open Eliom_content

Html5.D.string_select ~name:select_name
  (Html5.D.Option
    ([] (* attributes *),
     "Bob" (* value *),
     None (* Content, if different from value *),
     false (* not selected *))) (* first line *)
    [Html5.D.Option ([], "Marc", None, false);
     (Html5.D.Optgroup
        ([],
         "Girls",
         ([], "Karin", None, false),
         [([a_disabled `Disabled], "Juliette", None, false);
          ([], "Alice", None, true);
          ([], "Germaine", Some (pcdata "Bob's mother"), false)]))]

There is also int_select, float_select, etc. depending on the type expected by the service.

Basic HTML5 elements without Eliom services

For example if you want to use them with client side event handler.

open Eliom_content.Html5.D

Raw.select [option (pcdata "hello");
            option ~a:[a_value "a"; a_selected `Selected] (pcdata "cool")]

Links