From 0f7314ea019a42e202346fc429330f1e8dfa9b7d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 30 May 2005 08:13:34 +0000 Subject: r7093: - added a new Form() ejs object for producing simple forms. - tidied up the html generation a bit (This used to be commit ddccf6d2f5c4757111010e3116b41e379a7dc2dd) --- swat/esptest/exception.esp | 6 ------ swat/esptest/formtest.esp | 36 ++++++++++++++---------------------- swat/esptest/session.esp | 13 +------------ swat/esptest/showvars.esp | 8 +------- 4 files changed, 16 insertions(+), 47 deletions(-) (limited to 'swat/esptest') diff --git a/swat/esptest/exception.esp b/swat/esptest/exception.esp index abea890d98..cfd0f312fa 100644 --- a/swat/esptest/exception.esp +++ b/swat/esptest/exception.esp @@ -5,16 +5,10 @@
-
<% if (request['REQUEST_METHOD'] == "POST") { - /* if they cancelled then take them back to the list of tests */ - if (form['submit'] == "Cancel") { - redirect("/"); - } - function TestFunction(arg1, arg2) { return "OK"; } diff --git a/swat/esptest/formtest.esp b/swat/esptest/formtest.esp index 89e542c552..2d3693355c 100644 --- a/swat/esptest/formtest.esp +++ b/swat/esptest/formtest.esp @@ -1,34 +1,26 @@ <% page_header("columns", "ESP Form Test"); %> -
- firstName:
- lastName:
- -
-
+<% +var f = Form("FormTest", 2, 2); +f.element[0].label = "First Name"; +f.element[0].name = "firstName"; +f.element[1].label = "Last Name"; +f.element[1].name = "lastName"; +f.submit[0] = "OK"; +f.submit[1] = "Cancel"; + +display_form(f); <% /* if its a post then the user has filled in the form, so report the values */ - if (request['REQUEST_METHOD'] == "POST") { - - /* if they cancelled then take them back to the list of tests */ - if (form['submit'] == "Cancel") { - redirect("/"); - } + if (form['OK']) { %> - You chose firstName=@@form['firstName'] lastName=@@form['lastName'] + You chose firstName=@@form['firstName'] lastName=@@form['lastName']

+ <% - - function showArray(name, array) { - write("

Array: " + name + "

\n"); - for (v in array) { - write(name + "[" + v + "]=" + array[v] + "
\n"); - } - } - - showArray("form", form); + simple_table(form); } %> diff --git a/swat/esptest/session.esp b/swat/esptest/session.esp index 3d787012c6..ec747df442 100644 --- a/swat/esptest/session.esp +++ b/swat/esptest/session.esp @@ -43,18 +43,7 @@ if (request['REQUEST_METHOD'] == "POST") { } } -function showArray(name, array) { - write("

Array: " + name + "

\n"); - if (array == undefined) { - write("undefined
\n"); - return; - } - for (v in array) { - write(name + "[" + v + "]=" + array[v] + "
\n"); - } -} - -showArray("session", session); +simple_table(session); write("SessionId=" + request['SESSION_ID'] + "
\n"); %> diff --git a/swat/esptest/showvars.esp b/swat/esptest/showvars.esp index 262a0962b7..40008a0d7d 100644 --- a/swat/esptest/showvars.esp +++ b/swat/esptest/showvars.esp @@ -8,9 +8,7 @@ if (array == undefined) { write("undefined
\n"); } else { - for (v in array) { - write(name + "[" + v + "]=" + array[v] + "
\n"); - } + simple_table(array); } } @@ -23,10 +21,6 @@ showArray("session", session); %> -
-
-
- <% page_footer(); %> -- cgit