ASP Driven HTML Outlines

來源:互聯網
上載者:User
ASP Driven HTML Outlines
By Nannette Thacker - 08/13/1999

Have you ever wanted to create a web page in outline form? Here's how, using ASP Driven HTML and the Ordered List, <OL> command.

I have created two forms of outline sub procedures. The first I'll describe allows you to send a set of lines in the same outline level, without putting extra space between the lines. It consists of using three sub procedures. The second method uses only one sub procedure, but uses the equivalent of a paragraph space throughout all the lines.

Let's review the first method. There are three sub procedures for the outline: OutlineHead, OutlinePhrase, and OutlineFoot. If you're not a fast typist, you may wish to change the names to something shorter.

Here is how to use the three subs:

OutlineHead "I",1,1 OutlinePhrase "<B>I Test Outline</B>"OutlineFoot 1 

The OutlineHead sub takes three arguments: the type, the start, and the indent level. These commands are used as follows:

sub OutlineHead(otype,ostart,oindent)dim indentfor indent = 1 to oindentResponse.Write "<OL TYPE=""" & otype & """ START=" & ostart & ">" & vbCrLfnextend sub

A "for" loop is used to repeat the OL command for the number of indents needed. The "type" is used in the OL command to indicate the TYPE. Valid TYPE values are:

I, A, 1, a, and i

This indicates which outline type to use.

The "start" variable is used within the OL command to indicate the starting point. It takes a numeric value. If you want the outline level to start with I,A,1,a, or i, set the value to 1. If you want the outline level to start with III,C,3,c, or iii, set the value to 3, and so on.

The OutlinePhrase sub takes one parameter: the verbiage to display. You may optionally include HTML commands within this phrase.

sub OutlinePhrase(ophrase)Response.Write "<LI>" & ophrase & "</LI>" & vbCrLfend sub

The OutlinePhrase sub wraps the phrase with the List command and writes it to the user's browser.

OutlineFoot 1 

The OutlineFoot sub takes one parameter, the indent level. It uses a "for loop" to repeat the ending Ordered List command in order to exit the number of indent levels.

sub OutlineFoot(oindent)dim indentfor indent = 1 to oindentResponse.Write "</OL>" & vbCrLfnextend sub

When creating a group of lines within the same indent level, simply repeat the OutlinePhrase sub for as many lines are in the same level. The example code below was used to display the outline shown next:

OutlineHead "I",1,1 OutlinePhrase "<B>I Test Outline</B>"OutlineFoot 1 OutlineHead "A",1,2 OutlinePhrase "A Test Outline"OutlinePhrase "B Test Outline"OutlinePhrase "C Test Outline"OutlineFoot 2 OutlineHead "1",1,3 OutlinePhrase "1 Test Outline"OutlinePhrase "2 Test Outline"OutlinePhrase "3 Test Outline"OutlineFoot 3 OutlineHead "A",4,2 OutlinePhrase "D Test Outline"OutlinePhrase "E Test Outline"OutlineFoot 2 OutlineHead "1",1,3 OutlinePhrase "1 Test Outline"OutlinePhrase "2 Test Outline"OutlineFoot 3 OutlineHead "a",1,4 OutlinePhrase "a Test Outline"OutlinePhrase "b Test Outline"OutlineFoot 4 OutlineHead "i",1,5 OutlinePhrase "i Test Outline"OutlinePhrase "ii Test Outline"OutlineFoot 5 OutlineHead "a",3,4 OutlinePhrase "c Test Outline"OutlinePhrase "d Test Outline"OutlineFoot 4 

OutlineHead, OutlinePhrase, OutlineFoot example:

  1. I Test Outline
    1. A Test Outline
    2. B Test Outline
    3. C Test Outline
      1. 1 Test Outline
      2. 2 Test Outline
      3. 3 Test Outline
    1. D Test Outline
    2. E Test Outline
      1. 1 Test Outline
      2. 2 Test Outline
        1. a Test Outline
        2. b Test Outline
          1. i Test Outline
          2. ii Test Outline
        1. c Test Outline
        2. d Test Outline

The one sub outline procedure takes 5 arguments:

Outline "A Test Outline","A",1,2

The phrase, the TYPE, the START, and the indent level.

sub Outline(ophrase,otype,ostart,oindent)dim indentfor indent = 1 to oindentResponse.Write "<OL TYPE=""" & otype & """ START=" & ostart & ">" & vbCrLfnextResponse.Write "<LI>" & ophrase & "</LI>" & vbCrLffor indent = 1 to oindentResponse.Write "</OL>" & vbCrLfnextend sub

This is the easiest outline to implement, but it creates the paragraph space between all lines.

The code below was used to create the outline example below:

Outline "<B>I Test Outline</B>","I",1,1 Outline "A Test Outline","A",1,2Outline "B Test Outline","A",2,2Outline "C Test Outline","A",3,2Outline "1 Test Outline","1",1,3Outline "2 Test Outline","1",2,3Outline "3 Test Outline","1",3,3Outline "D Test Outline","A",4,2Outline "1 Test Outline","1",1,3Outline "2 Test Outline","1",2,3Outline "a Test Outline","a",1,4Outline "b Test Outline","a",2,4Outline "3 Test Outline","1",3,3Outline "E Test Outline","A",5,2Outline "<B>II Test Outline</B>","I",2,1 Outline "A Test Outline","A",1,2Outline "B Test Outline","A",2,2

Outline sub example:

  1. I Test Outline
    1. A Test Outline
    1. B Test Outline
    1. C Test Outline
      1. 1 Test Outline
      1. 2 Test Outline
      1. 3 Test Outline
    1. D Test Outline
      1. 1 Test Outline
      1. 2 Test Outline
        1. a Test Outline
        1. b Test Outline
      1. 3 Test Outline
    1. E Test Outline
  1. II Test Outline
    1. A Test Outline
    1. B Test Outline

For your cutting and pasting pleasure, the entire VBScript functions looks like this. (Put them in an include file please. Don't let me catch you pasting this on multiple pages!!

<SCRIPT LANGUAGE=VBScript RUNAT=Server>sub Outline(ophrase,otype,ostart,oindent)dim indentfor indent = 1 to oindentResponse.Write "<OL TYPE=""" & otype & """ START=" & ostart & ">" & vbCrLfnextResponse.Write "<LI>" & ophrase & "</LI>" & vbCrLffor indent = 1 to oindentResponse.Write "</OL>" & vbCrLfnextend subsub OutlineHead(otype,ostart,oindent)dim indentfor indent = 1 to oindentResponse.Write "<OL TYPE=""" & otype & """ START=" & ostart & ">" & vbCrLfnextend subsub OutlinePhrase(ophrase)Response.Write "<LI>" & ophrase & "</LI>" & vbCrLfend subsub OutlineFoot(oindent)dim indentfor indent = 1 to oindentResponse.Write "</OL>" & vbCrLfnextend sub</script>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.