Hi all,

I wrote a gui component +Radio to use html radio button, which I
missed in picolisp.  Just set *Radio to NIL and then call (gui
'(+Radio) N V) where N is a group where the radio button belongs to
and V is a value the radio button represents.

Code is bellow:

### +Radio

## Only the first one in a group holds the value.  Others just pretend
## to be the first for HTML rendering and return NIL value.  *Radio
## must be set to NIL before a form is rendered.

(default *Radio NIL)

(class +Radio +field)
# grp xval lbl 1st

# (grp xval [lbl])
(dm T (Grp Xval Lbl)
   (=: grp Grp)
   (=: xval Xval)
   (=: lbl Lbl)
   (=: 1st (assoc Grp *Radio))
   (unless (: 1st)
      (push '*Radio (list Grp This (length (get *Top 'gui)))))
   (super) )

(dm txt> (Val)
   Val)

(dm show> ("Var")
   (showFld
      (ifn (: 1st)
         (<radio> "Var" (: xval) (not (able)))
         (prin "<input type=\"radio\" name=\"*Gui(+"
            (+ 1 (caddr (: 1st))) ")\"")
         (prin " value=\"" (: xval) "\""
            (when (= (ifn (: 1st)
                        (val> This)
                        (with (cadr (: 1st)) (val> This)))
                     (: xval))
               " checked=\"checked\"") )
         (dfltCss "radio")
         (and (not (able)) (prin " disabled=\"disabled\""))
         (prinl "/>") )))

(dm set> (Val Dn)
   (unless (: 1st)
      (super Val Dn)))

(dm val> ()
   (unless (: 1st)
      (super)))

Hope you find it useful too.

Cheers,

Tomas
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

Reply via email to