def entry(form): checkbox = """ C1<input type=checkbox name=check1><br/> C2<input type=checkbox name=check2><br/> C3<input type=checkbox name=check3><br/> """ radiobuttons = """ R1<input type=radio name=choice value=1><br/> R2<input type=radio name=choice value=2><br/> R3<input type=radio name=choice value=3><br/> """ submit = """ <input type='submit' name='submit' value='confirm'> """ return cgipage(html_form(checkbox + radiobuttons + submit)) def exit(form): return cgipage( interp( """Thank you. You submitted:<br/> check1 $check1<br/> check2 $check2<br/> check3 $check3<br/> choice $choice<br/> """, form)) if __name__ == "__main__": print cgiform(entry, exit)
#!/usr/bin/python2.4 import os, sys, cgi from ms.html_utils import cgipage, cgiform, getscriptname, interp, html_form def entry(form): checkbox=""" C1<input type=checkbox name=check1><br/> C2<input type=checkbox name=check2><br/> C3<input type=checkbox name=check3><br/> """ radiobuttons=""" R1<input type=radio name=choice value=1><br/> R2<input type=radio name=choice value=2><br/> R3<input type=radio name=choice value=3><br/> """ submit=""" <input type='submit' name='submit' value='confirm'> """ return cgipage(html_form(checkbox + radiobuttons + submit)) def exit(form): return cgipage(interp("""Thank you. You submitted:<br/> check1 $check1<br/> check2 $check2<br/> check3 $check3<br/> choice $choice<br/> """, form)) if __name__ == "__main__": print cgiform(entry, exit)
yield "<tr>" yield "<td>%s</td>" % o_arg.help yield "<td><input type='text' name=%r value=%r></td>" % (name, val) yield "</tr>" @template() def inputform(option, op): yield "<form action=%r>" % getscriptname() yield "<table summary='Input form'>" yield entrybox(option, op.get_option_args()) yield checkbox(option, op.get_flags()) yield "</table>" yield "<input type='submit' name='submit' value='confirm'>" yield "</form>" def entryform(form): printpage(inputform(option, op), title="Example 1") def exitform(form): printpage("Thank you for filling this form.") if __name__ == "__main__": op = option_parser_from(__doc__) op.add_option("-S", "--submit", action="store_true", default=False, help="Submit the form") option, args = op.parse_args() if option.submit: # script called from the command line os.environ["QUERY_STRING"] = "&submit=confirm" cgiform(entryform, exitform)