| <!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
| <HTML> |
| <HEAD> |
| <TITLE>checkbox</TITLE> |
| </HEAD> |
| <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#1F00FF" ALINK="#FF0000" VLINK="#9900DD"> |
| <A NAME="top"> |
| <A NAME="file1"> |
| <H1>checkbox.ws3</H1> |
| |
| <PRE> |
| <I><FONT COLOR="#B22222"># |
| </FONT></I><I><FONT COLOR="#B22222"># This Example shows you how to handle checkboxes in a form. |
| </FONT></I><I><FONT COLOR="#B22222"># |
| </FONT></I> |
| <I><FONT COLOR="#B22222"># set flag |
| </FONT></I><B><FONT COLOR="#A020F0">set</FONT></B> first_load <B><FONT COLOR="#BC8F8F">"on"</FONT></B> |
| |
| |
| <I><FONT COLOR="#B22222"># see confirmation form example |
| </FONT></I><B><FONT COLOR="#A020F0">proc</FONT></B> <B><FONT COLOR="#0000FF">page</FONT></B> {<FONT COLOR="#B8860B">title code</FONT>} { |
| web::putx {<html><head><title>{web::put $<FONT COLOR="#B8860B">title</FONT>}</title></head> |
| <body bgcolor=<B><FONT COLOR="#BC8F8F">"#ffffff"</FONT></B> <B><FONT COLOR="#A020F0">text</FONT></B>=<B><FONT COLOR="#BC8F8F">"#000000"</FONT></B>> |
| <h3>{web::put $<FONT COLOR="#B8860B">title</FONT>}</h3> |
| } |
| <B><FONT COLOR="#A020F0">uplevel</FONT></B> $<FONT COLOR="#B8860B">code</FONT> |
| web::put <B><FONT COLOR="#BC8F8F">"</body></html>\n"</FONT></B> |
| } |
| |
| <I><FONT COLOR="#B22222"># see confirmation form example |
| </FONT></I><B><FONT COLOR="#A020F0">proc</FONT></B> <B><FONT COLOR="#0000FF">form</FONT></B> {<FONT COLOR="#B8860B">page code</FONT>} { |
| web::put <B><FONT COLOR="#BC8F8F">"<form enctype=\"text/html\" method=\"post\" action=\"[web::cmdurl $page]\">"</FONT></B> |
| <B><FONT COLOR="#A020F0">uplevel</FONT></B> $<FONT COLOR="#B8860B">code</FONT> |
| web::put <B><FONT COLOR="#BC8F8F">"</form>"</FONT></B> |
| } |
| |
| <B><FONT COLOR="#A020F0">proc</FONT></B> <B><FONT COLOR="#0000FF">showForm</FONT></B> {<FONT COLOR="#B8860B">error</FONT>} { |
| <B><FONT COLOR="#A020F0">global</FONT></B> first_load |
| <I><FONT COLOR="#B22222"># generate a page with Title "File upload example" |
| </FONT></I> page <B><FONT COLOR="#BC8F8F">"checkbox example"</FONT></B> { |
| <I><FONT COLOR="#B22222"># generate a form with action "submit" |
| </FONT></I> <I><FONT COLOR="#B22222"># the return value of a checkbox is no value or "on" |
| </FONT></I> form <B><FONT COLOR="#BC8F8F">"submit"</FONT></B> { |
| <I><FONT COLOR="#B22222"># web::match is used to search the value "on" in the variables time_flag and firstload. |
| </FONT></I><I><FONT COLOR="#B22222"># If the value is found it returns a checked. |
| </FONT></I> web::putx { |
| <br>Please choose the information that should be displayed.<br><br> |
| Time |
| <input name=<B><FONT COLOR="#BC8F8F">"time_flag"</FONT></B> type=<B><FONT COLOR="#BC8F8F">"checkbox"</FONT></B> {web::put [web::match <B><FONT COLOR="#BC8F8F">"checked"</FONT></B> [web::formvar time_flag $<FONT COLOR="#B8860B">first_load</FONT>] <B><FONT COLOR="#BC8F8F">"on"</FONT></B>]}> |
| Day |
| <input name=<B><FONT COLOR="#BC8F8F">"day_flag"</FONT></B> type=<B><FONT COLOR="#BC8F8F">"checkbox"</FONT></B> {web::put [web::match <B><FONT COLOR="#BC8F8F">"checked"</FONT></B> [web::formvar day_flag $<FONT COLOR="#B8860B">first_load</FONT>] <B><FONT COLOR="#BC8F8F">"on"</FONT></B>]}> |
| Date |
| <input name=<B><FONT COLOR="#BC8F8F">"date_flag"</FONT></B> type=<B><FONT COLOR="#BC8F8F">"checkbox"</FONT></B> {web::put [web::match <B><FONT COLOR="#BC8F8F">"checked"</FONT></B> [web::formvar date_flag $<FONT COLOR="#B8860B">first_load</FONT>] <B><FONT COLOR="#BC8F8F">"on"</FONT></B>]}> |
| <br> |
| {<B><FONT COLOR="#A020F0">set</FONT></B> output [web::match <B><FONT COLOR="#BC8F8F">"%T &nbsp;"</FONT></B> [web::formvar time_flag $<FONT COLOR="#B8860B">first_load</FONT>] <B><FONT COLOR="#BC8F8F">"on"</FONT></B>]} |
| {<B><FONT COLOR="#A020F0">append</FONT></B> output [web::match <B><FONT COLOR="#BC8F8F">"%A &nbsp;"</FONT></B> [web::formvar day_flag $<FONT COLOR="#B8860B">first_load</FONT>] <B><FONT COLOR="#BC8F8F">"on"</FONT></B>]} |
| {<B><FONT COLOR="#A020F0">append</FONT></B> output [web::match <B><FONT COLOR="#BC8F8F">"%d.%m.%Y"</FONT></B> [web::formvar date_flag $<FONT COLOR="#B8860B">first_load</FONT>] <B><FONT COLOR="#BC8F8F">"on"</FONT></B>]} |
| {web::put [<B><FONT COLOR="#A020F0">clock</FONT></B> <B><FONT COLOR="#A020F0">format</FONT></B> [<B><FONT COLOR="#A020F0">clock</FONT></B> seconds] -<B><FONT COLOR="#A020F0">format</FONT></B> $<FONT COLOR="#B8860B">output</FONT>]} |
| <br> |
| <input type=<B><FONT COLOR="#BC8F8F">"submit"</FONT></B> name=<B><FONT COLOR="#BC8F8F">"ok"</FONT></B> value=<B><FONT COLOR="#BC8F8F">"Send"</FONT></B>> |
| } |
| } |
| } |
| } |
| |
| |
| <I><FONT COLOR="#B22222"># see confirmation form example |
| </FONT></I>web::command default { |
| showForm 0 |
| } |
| |
| |
| <I><FONT COLOR="#B22222"># With the set first_load 0 we know that the showForm is not displayed |
| </FONT></I><I><FONT COLOR="#B22222"># the first time. |
| </FONT></I><I><FONT COLOR="#B22222"># See also confirmation form example. |
| </FONT></I> |
| web::command submit { |
| <B><FONT COLOR="#A020F0">set</FONT></B> first_load 0 |
| showForm 0 |
| } |
| |
| <I><FONT COLOR="#B22222">#see dispatch example |
| </FONT></I>web::dispatch</PRE> |
| <HR> |
| <ADDRESS>Generated by <A HREF="http://www.iki.fi/~mtr/genscript/">GNU enscript 1.6.3</A>.</ADDRESS> |
| </BODY> |
| </HTML> |