|
Ordered Lists
| [Previous] [Main] [Next] |
|
| |
| An ordered list is a list in which the list items are numbered, and is useful for displaying items that appear in a specific sequence, such as chapter titles or step-by-step instructions.
| |
|
| |
| To create an ordered list, specify ordered_list as the first argument to the htmlList constructor, or use the Type() method.
| |
|
| |
| Several options exist for specifying the numbering style used for the list:
| |
|
| |
| The numbering style can be specified as the second argument in the constructor, or via the Numbering() method.
| |
|
| |
| By default, list items begin numbering with the number one. You can, however, begin numbering any value you wish by setting the starting number using the Start() or SequenceNumber() methods.
| |
|
| |
| If you have several ordered lists on a page, each list will begin numbering at one. It's often convenient to have information appear between adjacent lists while retaining the number sequence. In such cases, you can use the Continue() method to set the list to resume numbering from where the previous list ended.
| |
|
| |
|
| |
| #include <stdio.h>
| |
| #include <stdlib.h>
| |
| #include <dcmicro/htmlpp/htmlpp.h>
| |
|
| |
| int main( void )
| |
| {
| |
| htmlCgi server ;
| |
| htmlPage page( "html++ example application" ) ;
| |
|
| |
| // Construct a list using the default options
| |
| htmlList list1 ;
| |
| list1 << "One" ;
| |
| list1 << "Two" ;
| |
| list1 << "Three" ;
| |
|
| |
| // Construct another list using letter numbering
| |
| htmlList list2( ordered_list, number_uppercase_letter ) ;
| |
| list2 << "One" ;
| |
| list2 << "Two" ;
| |
| list2 << "Three" ;
| |
|
| |
| page << "Default list"
| |
| << list1 ;
| |
|
| |
| page << "Letter-numbered list"
| |
| << list2 ;
| |
|
| |
| server << page ;
| |
| return 0 ;
| |
| }
| |
|
| |
|
| |
| Content-Type: text/html
| |
| <HTML>
| |
| <HEAD>
| |
| <TITLE>html++ example application</TITLE>
| |
| </HEAD>
| |
| <BODY>
| |
| Default list<OL><LI>One</LI>
| |
| <LI>Two</LI>
| |
| <LI>Three</LI>
| |
| </OL>
| |
| Letter-numbered list<OL TYPE="A"><LI>One</LI>
| |
| <LI>Two</LI>
| |
| <LI>Three</LI>
| |
| </OL>
| |
| </BODY>
| |
| </HTML>
| |
|
| |
|
| |
|
| |
| Lists can be also nested. To create a sublist with it's own set of numbers, simply instantiate another htmlList object, populate it with the list items of interest, then insert the entire list into the parent list.
| |
|
| |
|
| |
| #include <stdio.h>
| |
| #include <stdlib.h>
| |
| #include <dcmicro/htmlpp/htmlpp.h>
| |
|
| |
| int main( void )
| |
| {
| |
| htmlCgi server ;
| |
| htmlPage page( "html++ example application" ) ;
| |
|
| |
| // Create a list to insert in the main list
| |
| htmlList directions ( ordered_list,
| |
| number_lowercase_letter ) ;
| |
| directions << "Remove knife from drawer"
| |
| << "Remove lid from jelly jar"
| |
| << "Scoop jelly from jar using knife"
| |
| << "Spread jelly evenly across bread" ;
| |
|
| |
| // Create a list that contains the first list
| |
| // (the constructor defaults to ordered_list).
| |
| htmlList sandwich ;
| |
| sandwich << "Open refrigerator"
| |
| << "Grab 2 slices of bread"
| |
| << "Grab jelly"
| |
| << "Open cabinet"
| |
| << "Grab peanut butter"
| |
| << "Apply jelly to one slice of bread"
| |
| << directions
| |
| << "Apply peanut butter to other "
| |
| "slice of bread" ;
| |
|
| |
| // Output the list to the page
| |
| page << htmlHeading( 1, "How to make a sandwich" )
| |
| << sandwich ;
| |
|
| |
| server << page ;
| |
| return 0 ;
| |
| }
| |
|
| |
|
| |
| Content-Type: text/html
| |
| <HTML>
| |
| <HEAD>
| |
| <TITLE>html++ example application</TITLE>
| |
| </HEAD>
| |
| <BODY>
| |
| <H1>How to make a sandwich</H1>
| |
| <OL><LI>Open refrigerator</LI>
| |
| <LI>Grab 2 slices of bread</LI>
| |
| <LI>Grab jelly</LI>
| |
| <LI>Open cabinet</LI>
| |
| <LI>Grab peanut butter</LI>
| |
| <LI>Apply jelly to one slice of bread</LI>
| |
| <OL TYPE="a"><LI>Remove knife from drawer</LI>
| |
| <LI>Remove lid from jelly jar</LI>
| |
| <LI>Scoop jelly from jar using knife</LI>
| |
| <LI>Spread jelly evenly across bread</LI>
| |
| </OL>
| |
| <LI>Apply peanut butter to other slice of bread</LI>
| |
| </OL>
| |
| </BODY>
| |
| </HTML>
| |
|
| |
| |
|
| |
