Make add examples look the same.

This commit is contained in:
interp 2003-01-16 12:09:49 +00:00
parent 0656602636
commit c9c7eb0a90
3 changed files with 17 additions and 17 deletions

View File

@ -17,7 +17,7 @@
(p (p
(form (@ (method "get") (form (@ (method "get")
(action ,new-url)) (action ,new-url))
,input-text ,input-text " "
(input (@ (type "text") (input (@ (type "text")
(name "number")) (name "number"))
(input (@ (type "submit")))))) (input (@ (type "submit"))))))
@ -43,11 +43,12 @@
(send-html/suspend (send-html/suspend
(lambda (new-url) (lambda (new-url)
`(html (title "Result") `(html (title "Result")
(body (h1 "Result") (body (h2 "Result")
(p ,(number->string (+ (get-number1) (get-number2)))) (p ,(number->string (+ (get-number1) (get-number2))))
(a (@ (href "add.scm")) "new calculation (new session)")(br) (hr)
(a (@ (href "javascript:history.back(2)")) "new calculation (same session)")(br) (a (@ (href "add.scm")) "New calculation (new session)")(br)
(a (@ (href ,new-url)) "close this session"))))))) (a (@ (href "javascript:history.back(2)")) "New calculation (same session)")(br)
(a (@ (href ,new-url)) "Close this session")))))))
;; How to clear session data and go to another HTML page: ;; How to clear session data and go to another HTML page:
(send/finish (send/finish
(make-error-response (status-code moved-temp) req (make-error-response (status-code moved-temp) req

View File

@ -64,7 +64,7 @@
<HTML> <HTML>
<TITLE>Result</TITLE> <TITLE>Result</TITLE>
<BODY> <BODY>
<H1>Result</H1> <H2>Result</H2>
<P> <P>
~a ~a
<P> <P>

View File

@ -7,16 +7,15 @@
scheme-with-scsh) scheme-with-scsh)
(begin (begin
(define number-input-field (make-number-input-field '(@ (maxlength 10)))) (define number-input-field (make-number-input-field))
(define (get-number input-text . maybe-update-text) (define (get-number title input-text)
(let* ((update-text (:optional maybe-update-text "")) (let* ((result
(result
(send-html/suspend (send-html/suspend
(lambda (new-url) (lambda (new-url)
`(html (title ,input-text) `(html (title ,title)
(body (body
(p (font (@ (color "red")) ,update-text)) (h2 ,title)
(p (p
(servlet-form ,new-url (servlet-form ,new-url
,input-text " " ,input-text " "
@ -28,21 +27,21 @@
(if result (if result
(or (input-field-value number-input-field (or (input-field-value number-input-field
(form-query (http-url-search (request-url result)))) (form-query (http-url-search (request-url result))))
(get-number input-text "Please enter a valid number.")) (get-number title "Please enter a valid number."))
(get-number input-text "Please enter a number.")))) (get-number title "Please enter a number."))))
(define (get-number1) (define (get-number1)
(get-number "First number:")) (get-number "Calculation - Step one" "First number:"))
(define (get-number2) (define (get-number2)
(get-number "Second number:")) (get-number "Calculation - Step two" "Second number:"))
(define (main req) (define (main req)
(let ((number1 (get-number1)) (let ((number1 (get-number1))
(number2 (get-number2))) (number2 (get-number2)))
(send-html (send-html
`(html (title "Result") `(html (title "Result")
(body (h1 "Result") (body (h2 "Result")
(p ,(number->string (+ number1 number2))) (p ,(number->string (+ number1 number2)))
(hr) (hr)
(p (URL "add2.scm" "Make new calculation.") (br) (p (URL "add2.scm" "Make new calculation.") (br)