[racket] Web input-string with pre-fllled value

From: Mark Carter (mcturra2000 at yahoo.co.uk)
Date: Tue Aug 24 14:18:17 EDT 2010

I'm trying to construct a simple tax calculator in Racket for use over the web. 
Here's my code so far:

#lang web-server/insta

(require web-server/formlets)

(define new-post-formlet
   (div "Amount: " ,{input-string . => . amount}
        ;,(select-input '("Net" "Gross") . => . type)
        (p "")
        "VAT Rate: " ,{input-string . => . rate}
   (p "still in form"))
   (values amount rate)))

(define (render-vat-page amount rate request)
  (local [(define (response-generator make-url)
            `(html (head (title "My Calculator"))
                    (h1 "Simple VAT calculator")
                    (form ([action
                            ,(make-url insert-vat-handler)])
                          ,@(formlet-display new-post-formlet)
                          (input ([type "submit"])))
                    (p ,amount)
                    (p ,rate))))
          (define (insert-vat-handler request)
            (define-values (amount rate)
              (formlet-process new-post-formlet request))
            (print "insert-post-handle")
            (print amount)
            (render-vat-page amount rate (redirect/get)))]
    (send/suspend/dispatch response-generator)))

; start: request -> html-response
(define (start request)
  (render-vat-page "0.0" "17.5" request))

I would like to pre-fill the VAT Rate input-string with a rate (set to 17.5 as a 
default). Is there a way I can do that?

Also, is there a way I can give the submit button a label other than "Submit 


Posted on the users mailing list.