This site applies only to CMPT 165 (Distance Ed) in Summer 2016. See the CMPT 165 sections page for other sections.
This lab is intended to get you started working with form input.
-
Create an XHTML form that asks the use for their name and their age. Name this file
age.html
. The “action” of this form should be the Python program you create below.Create a web script that takes the form data from that page. Name this file
result.py
. It should create XHTML with content like this (inside the<body>
):<p>Hello, name.</p>
<p>Next year, you will be X years old.</p>The word
name
should be replaced with the name the user entered. TheX
should be replaced with the age they entered plus one.In order to add one to the age the user enters, you will have to convert it to a number. This can be done with the
int
function, as inint(form.getvalue("age"))
. -
First, check your
age.html
file and make sure it's valid.The XHTML code that your program generates should also be valid XHTML. That means (among other things) that your program will have to print out a doctype. You can check the validity in one of two ways.
When your page is online an functioning, you can copy-and-paste the URL with the query string to the validator. The URL will be something like this:
http://cmpt165.csil.sfu.ca/~userid/lab9/result.py?name=Your%20Name&age=20
The other option is to view the result page, view the page source in your browser, and copy-and-paste the code into the “enter HTML code directly” section in a validator.
Submit the URL of the form page to CourSys.