Page 267 -
P. 267
web development
This is typically either
“POST” or “GET”.
def start_form(the_url, form_type="POST"):
return('<form action="' + the_url + '" method="' + form_type + '">')
This function returns the HTML for the start of a form and lets the caller
specify the URL to send the form’s data to, as well as the method to use.
def end_form(submit_msg="Submit"):
return('<p></p><input type=submit value="' + submit_msg + '"></form>')
This function returns the HTML markup, which terminates the form while
allowing the caller to customize the text of the form’s “submit” button.
def radio_button(rb_name, rb_value):
return('<input type="radio" name="' + rb_name +
'" value="' + rb_value + '"> ' + rb_value + '<br />')
Given a radio-button name and value, create a HTML radio button (which is
typically included within a HTML form). Note: both arguments are required.
def u_list(items):
u_string = '<ul>'
A simple “for” for item in items:
loop does the u_string += '<li>' + item + '</li>'
trick. u_string += '</ul>'
return(u_string)
Given a list of items, this function turns the list into a HTML unnumbered
list. A simple “for” loop does all the work, adding a LI to the UL element
with each iteration.
def header(header_text, header_level=2):
return('<h' + str(header_level) + '>' + header_text +
'</h' + str(header_level) + '>')
Create and return a HTML header tag (H1, H2, H2, and so on) with level 2
as the default.. The “header_text” argument is required.
def para(para_text):
return('<p>' + para_text + '</p>')
Enclose a paragraph of text (a string) in HTML paragraph tags. Almost not
worth the effort, is it?
you are here 4 231