You are looking at historical revision 13621 of this page. It may differ significantly from its current revision.


The html-form library is intended to construct HTML form descriptions in an s-expression syntax that are then passed to an HTML generation routine.

Library procedures

html-form:: SPEC -> SXML

This is the only exported routine in this egg. Given a form specification, returns an SXML document containing an HTML form. SPEC is an s-expression with the following grammar:

 SPEC = (form-group NAME [(label LABEL)] (children ...) ) 
        | WIDGET
 WIDGET =     (checkbox NAME DFLT [(label LABEL)] [(rel REL)] ) 
              (textarea NAME DFLT (rows N) (cols N) [(label LABEL)] [(rel REL)] ) 
              (select   NAME DFLT [(label LABEL)] [(rel REL)] ) 
              (button   NAME DFLT [(label LABEL)] [(rel REL)] [(onclick STRING)] )
              (radio    NAME DFLT [(label LABEL)] [(rel REL)] ( (RNAME ROPTS) ... ) )
              (text     NAME DFLT [(label LABEL)] [(rel REL)] )

NAME, LABEL and REL are symbols or strings. DFLT is the default value of an input, or a list of values in the case of textarea and select.


(use html-form)
(define Country-List
   "American Samoa"
(define form-variables
   (form-group Personal-Data (label "Personal Data")
                (First-Name         ""  (label "First Name * "))
                (Last-Name          ""  (label "Last Name * "))
                (email              ""  (label "Email address * "))
                (Nationality        ""  (label "Nationality *")
                                    (select ,Country-List))
                (Birth-Year         ""
                                    (label "Year of birth *")
                                    (select ,(list-tabulate 50 (lambda (i) (number->string (+ 1940 i))))))
                (Gender             "" 
                                    (label "Gender *")
                                    (select ("Female" "Male")))
   (form-group   Education (label "Education & professional background")
                  (Degree     "" (label "Last degree obtained ")
                                    ("Bachelor of Science"
                                     "Master of Science"
                                     "Current undergraduate student")))
                  (Major      "" (label "Academic major ")
                                    ("Artificial Intelligence"
                  (Degree-Other ""   (label "Degree obtained if other "))
                  (Education-History ""  
                                     (label "Education history")
                                     (hint "Please list year, institution, and highest degree obtained. ")
                                     (textarea (rows 10) (cols 60)))
  (pretty-print (map (lambda (x) (html-form x)) form-variables))


Ivan Raikov


Initial version


Copyright 2008 Ivan Raikov and the Okinawa Institute of Science and Technology.

html-form is distributed along with the wFORMS 2.0 Stylesheet, copyright 2005-2006 Cedric Savarese (

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

A full copy of the GPL license can be found at <>.