Hello Experts,
I have this page, is working but i'm looking forward to show the province at the top then the list and is not working with me here is the code.
I want the province to show first then the other lists...
http://www.apprenticetrades.ca/EN/displayContent/default.asp?userAction=LOADARTICLE&txtArticleID=1074Examples:
List of Apprenticeship Trades
TABLE OF CONTENTS
Nunavut
Northwest Territories
....
Newfoundland and Labrador
Interprovincial (Red Seal) Trades
Page 1 of 14
Previous Page | Next Page
--------------------------
----------
----------
----------
----------
----------
----------
--
Apprenticeship Trades in Nunavut
Aerospace/Aviation
Aircraft Maintenance Enginner
..
.
..
.
Here is the all the code of this page... PLEASE HELP !!
<%@ Language=VBScript %>
<%Option Explicit%>
<!--#include virtual="/inc/rout.inc"-->
<!--#include virtual="/inc/db.inc"-->
<%
'=========================
==========
==========
==========
==========
==========
===
' AppName = CAF-FCA Canadian Apprenticeship Forum
'=========================
==========
==========
==========
==========
==========
===
'
' VSS Version: $Revision: 10 $
' Last Modified by: $Author: Ttf $
' Last Checkin: $Date: 5/01/04 1:03p $
' Last Modification Time: $Modtime: 5/01/04 11:46a $
' FileName: $Workfile: default.asp $
'
' Description: Display Content page displays content articles from the database OR from a parent
' pages' form using javascript when displayed in an IFRAME, when previewing articles in ADMIN area.
'
'=========================
==========
==========
==========
==========
==========
===
' DO NOT EDIT VERSION INFO ABOVE - Automatically updated by SourceSafe at Check-in
'-------------------------
----------
----------
----------
----------
----------
---
' BEGIN Global Server-side Variables
' --------------------------
----------
----------
----------
----------
----------
-
Dim blnDebug, strDebug, oConn
'to enable debugging
blnDebug = false
Dim search_results_page 'used to determine which header inc file is in use and toggle content display
Dim vac_page_links 'used by content
dim strMsgToUser 'used to provide action or error messages to the user after processing
Dim strPaginationControl, iArticleID, iCurrentPgNum, iTotalPgNum, arrPageTitles()
dim strTitle, strCredit, strAuthor, strArticleBody, strPreviewMode, strAuthorCredit, strTableOfContents
'-------------------------
----------
----------
----------
----------
----------
---
' END Global Server-side Variables
' --------------------------
----------
----------
----------
----------
----------
-
call Main() 'controls page logic for form submissions
%>
<!-- #include virtual="/en/includes/html
head.inc" -->
<title>ApprenticeTrades.ca
: Value Added Content</title>
<!-- #include virtual="/en/includes/head
er.inc" -->
<script language="javascript">
function SubmitForm(mode, arg1)
{
var form = window.document.form1;
switch (mode)
{
case "BACK":
var iPg
iPg = form.iCurrentPgNum.value;
form.iCurrentPgNum.value = Number(iPg) - 1;
form.userAction.value = "LOADBODYPAGE";
break;
case "FORWARD":
var iPg
iPg = form.iCurrentPgNum.value;
if (!iPg) { iPg = 1; }
form.iCurrentPgNum.value = Number(iPg) + 1;
form.userAction.value = "LOADBODYPAGE";
break;
case "JUMPTOPAGE":
form.iCurrentPgNum.value = arg1;
form.userAction.value = "LOADBODYPAGE";
break;
}
//alert("submitTo:" + form.action);
form.submit();
}
</script>
<!-- content begins -->
<%= strMsgToUser%>
<form name="form1" method="post" action="default.asp">
<input type="hidden" name="previewMode" value="<%= strPreviewMode%>">
<input type="hidden" name="iCurrentPgNum" value="<%= iCurrentPgNum%>">
<input type="hidden" name="userAction" value="">
<input type="hidden" name="iTotalPgNum" value="<%= iTotalPgNum%>">
<input type="hidden" name="txtArticleID" value="<%= Server.HTMLEncode(iArticle
ID)%>">
<input type="hidden" name="txtTitle" value="<%= Server.HTMLEncode(strTitle
)%>">
<input type="hidden" name="txtCredit" value="<%= Server.HTMLEncode(strCredi
t)%>">
<input type="hidden" name="txtAuthor" value="<%= Server.HTMLEncode(strAutho
r)%>">
</form>
<p class="articleTitle" ><%= strTitle%></p>
<%= strArticleBody %>
<%= strAuthorCredit %>
<!-- content ceases -->
<!-- #include virtual="/en/includes/foot
er.inc" -->
<%
'-------------------------
----------
----------
----------
----------
----------
---
' BEGIN Server-side functions
' --------------------------
----------
----------
----------
----------
----------
-
sub Main()
CreateGlobalObjects
vac_page_links = "true" 'used by content to optionally include the pagination control at bottom of footer
iCurrentPgNum = rq("iCurrentPgNum")
iTotalPgNum = rq("iTotalPgNum")
if iTotalPgNum <> "" then
iTotalPgNum = cint(iTotalPgNum)
end if
if iCurrentPgNum = "" then
iCurrentPgNum = 1
else
iCurrentPgNum = cint(iCurrentPgNum)
end if
iArticleID = rq("txtArticleID")
strAuthor = rq("txtAuthor")
strCredit = rq("txtCredit")
strTitle = rq("txtTitle")
Dim strAction
strAction = rq("userAction")
strPreviewMode = rq("previewMode")
select case strAction
case "LOADARTICLE":
iCurrentPgNum = 1
call LoadArticle()
case "LOADARTICLE2":
iCurrentPgNum = 2
call LoadArticle2()
case "LOADARTICLE3":
iCurrentPgNum = 3
call LoadArticle3()
case "LOADARTICLE4":
iCurrentPgNum = 4
call LoadArticle4()
case "LOADARTICLE5":
iCurrentPgNum = 5
call LoadArticle5()
case "LOADARTICLE6":
iCurrentPgNum = 6
call LoadArticle6()
case "LOADARTICLE7":
iCurrentPgNum = 7
call LoadArticle7()
case "LOADARTICLE8":
iCurrentPgNum = 8
call LoadArticle8()
case "LOADARTICLE9":
iCurrentPgNum = 9
call LoadArticle9()
case "LOADBODYPAGE":
strArticleBody = LoadBodyPage(iCurrentPgNum
)
case "PREVIEWARTICLE":
iTotalPgNum = cint(rq("iBodyPageNum"))
strPreviewMode = "true"
call LoadPreviewArticle()
case else
'currently nothing special to do
end select
'iCurrentPgNum and iTotalPgNum declared in apprenticeship_finder.inc and populated in GetTrades()
strPaginationControl = WritePaginationControl("EN
",iTotalPg
Num,iCurre
ntPgNum)
strTableOfContents = PopulateTableOfContents
strAuthorCredit = WriteAuthorCredit()
if blnDebug then
AddToDebugString "iArticleID=" & iArticleID, true
end if
CleanUpGlobalObjects
end sub
sub CreateGlobalObjects
set oConn = Server.CreateObject("ADODB
.Connectio
n")
oConn.Open ConnectString
end sub
sub CleanUpGlobalObjects
if oConn.state = 1 then
oConn.close
end if
set oConn = nothing
end sub
sub LoadPreviewArticle()
on error resume next
'load the article from the parent page form, not database, since we could be previewing an unsaved version of an article
strTitle = "<script language=javascript>docume
nt.write(p
arent.docu
ment.form1
.txtTitle.
value);</s
cript>"
strArticleBody = LoadBodyPage(1)
end sub
sub LoadArticle()
on error resume next
dim strSQL, adoRS
if iArticleID <> "" then
strSQL = "SELECT * FROM ART_Articles WHERE ArticleID = " & rq("txtArticleID")
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.Open strSQL, oConn
if adoRS.State = 1 then
if not (adoRS.EOF OR adoRS.BOF) then
strTitle = adoRS("Title")
strAuthor = adoRS("Author")
strCredit = adoRS("Credit")
iTotalPgNum = adoRS("TotalPages")
strArticleBody = LoadBodyPage(1)
else
FormatMsgToUser "The requested article could not be found."
end if
end if
if err.number <> 0 then
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
AddToDebugString "Error:LoadArticle(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
else
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
end if
end sub
' ==========================
==========
==========
==========
==========
=========
' Load articles 2
' Start
sub LoadArticle2()
on error resume next
dim strSQL, adoRS
if iArticleID <> "" then
strSQL = "SELECT * FROM ART_Articles WHERE ArticleID = " & rq("txtArticleID")
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.Open strSQL, oConn
if adoRS.State = 1 then
if not (adoRS.EOF OR adoRS.BOF) then
strTitle = adoRS("Title")
strAuthor = adoRS("Author")
strCredit = adoRS("Credit")
iTotalPgNum = adoRS("TotalPages")
strArticleBody = LoadBodyPage(2)
else
FormatMsgToUser "The requested article could not be found."
end if
end if
if err.number <> 0 then
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
AddToDebugString "Error:LoadArticle(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
else
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
end if
end sub
' ==========================
==========
==========
==========
=========
' End Articles 2
' ==========================
==========
==========
==========
==========
=========
' Load articles 3
' Start
sub LoadArticle3()
on error resume next
dim strSQL, adoRS
if iArticleID <> "" then
strSQL = "SELECT * FROM ART_Articles WHERE ArticleID = " & rq("txtArticleID")
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.Open strSQL, oConn
if adoRS.State = 1 then
if not (adoRS.EOF OR adoRS.BOF) then
strTitle = adoRS("Title")
strAuthor = adoRS("Author")
strCredit = adoRS("Credit")
iTotalPgNum = adoRS("TotalPages")
strArticleBody = LoadBodyPage(3)
else
FormatMsgToUser "The requested article could not be found."
end if
end if
if err.number <> 0 then
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
AddToDebugString "Error:LoadArticle(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
else
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
end if
end sub
' ==========================
==========
==========
==========
=========
' End Articles 3
' ==========================
==========
==========
==========
==========
=========
' Load articles 4
' Start
sub LoadArticle4()
on error resume next
dim strSQL, adoRS
if iArticleID <> "" then
strSQL = "SELECT * FROM ART_Articles WHERE ArticleID = " & rq("txtArticleID")
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.Open strSQL, oConn
if adoRS.State = 1 then
if not (adoRS.EOF OR adoRS.BOF) then
strTitle = adoRS("Title")
strAuthor = adoRS("Author")
strCredit = adoRS("Credit")
iTotalPgNum = adoRS("TotalPages")
strArticleBody = LoadBodyPage(4)
else
FormatMsgToUser "The requested article could not be found."
end if
end if
if err.number <> 0 then
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
AddToDebugString "Error:LoadArticle(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
else
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
end if
end sub
' ==========================
==========
==========
==========
=========
' End Articles 4
' ==========================
==========
==========
==========
==========
=========
' Load articles 5
' Start
sub LoadArticle5()
on error resume next
dim strSQL, adoRS
if iArticleID <> "" then
strSQL = "SELECT * FROM ART_Articles WHERE ArticleID = " & rq("txtArticleID")
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.Open strSQL, oConn
if adoRS.State = 1 then
if not (adoRS.EOF OR adoRS.BOF) then
strTitle = adoRS("Title")
strAuthor = adoRS("Author")
strCredit = adoRS("Credit")
iTotalPgNum = adoRS("TotalPages")
strArticleBody = LoadBodyPage(5)
else
FormatMsgToUser "The requested article could not be found."
end if
end if
if err.number <> 0 then
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
AddToDebugString "Error:LoadArticle(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
else
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
end if
end sub
' ==========================
==========
==========
==========
=========
' End Articles 5
' ==========================
==========
==========
==========
==========
=========
' Load articles 6
' Start
sub LoadArticle6()
on error resume next
dim strSQL, adoRS
if iArticleID <> "" then
strSQL = "SELECT * FROM ART_Articles WHERE ArticleID = " & rq("txtArticleID")
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.Open strSQL, oConn
if adoRS.State = 1 then
if not (adoRS.EOF OR adoRS.BOF) then
strTitle = adoRS("Title")
strAuthor = adoRS("Author")
strCredit = adoRS("Credit")
iTotalPgNum = adoRS("TotalPages")
strArticleBody = LoadBodyPage(6)
else
FormatMsgToUser "The requested article could not be found."
end if
end if
if err.number <> 0 then
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
AddToDebugString "Error:LoadArticle(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
else
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
end if
end sub
' ==========================
==========
==========
==========
=========
' End Articles 6
' ==========================
==========
==========
==========
==========
=========
' Load articles 7
' Start
sub LoadArticle7()
on error resume next
dim strSQL, adoRS
if iArticleID <> "" then
strSQL = "SELECT * FROM ART_Articles WHERE ArticleID = " & rq("txtArticleID")
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.Open strSQL, oConn
if adoRS.State = 1 then
if not (adoRS.EOF OR adoRS.BOF) then
strTitle = adoRS("Title")
strAuthor = adoRS("Author")
strCredit = adoRS("Credit")
iTotalPgNum = adoRS("TotalPages")
strArticleBody = LoadBodyPage(7)
else
FormatMsgToUser "The requested article could not be found."
end if
end if
if err.number <> 0 then
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
AddToDebugString "Error:LoadArticle(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
else
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
end if
end sub
' ==========================
==========
==========
==========
=========
' End Articles 7
' ==========================
==========
==========
==========
==========
=========
' Load articles 8
' Start
sub LoadArticle8()
on error resume next
dim strSQL, adoRS
if iArticleID <> "" then
strSQL = "SELECT * FROM ART_Articles WHERE ArticleID = " & rq("txtArticleID")
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.Open strSQL, oConn
if adoRS.State = 1 then
if not (adoRS.EOF OR adoRS.BOF) then
strTitle = adoRS("Title")
strAuthor = adoRS("Author")
strCredit = adoRS("Credit")
iTotalPgNum = adoRS("TotalPages")
strArticleBody = LoadBodyPage(8)
else
FormatMsgToUser "The requested article could not be found."
end if
end if
if err.number <> 0 then
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
AddToDebugString "Error:LoadArticle(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
else
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
end if
end sub
' ==========================
==========
==========
==========
=========
' End Articles 8
' ==========================
==========
==========
==========
==========
=========
' Load articles 9
' Start
sub LoadArticle9()
on error resume next
dim strSQL, adoRS
if iArticleID <> "" then
strSQL = "SELECT * FROM ART_Articles WHERE ArticleID = " & rq("txtArticleID")
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.Open strSQL, oConn
if adoRS.State = 1 then
if not (adoRS.EOF OR adoRS.BOF) then
strTitle = adoRS("Title")
strAuthor = adoRS("Author")
strCredit = adoRS("Credit")
iTotalPgNum = adoRS("TotalPages")
strArticleBody = LoadBodyPage(9)
else
FormatMsgToUser "The requested article could not be found."
end if
end if
if err.number <> 0 then
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
AddToDebugString "Error:LoadArticle(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
else
FormatMsgToUser "The requested article cannot be displayed at this time. Please try again later."
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
end if
end sub
' ==========================
==========
==========
==========
=========
' End Articles 9
function PopulateTableOfContents
on error resume next
dim strResult, x, y, iActiveIndex, strTestTitles
strResult = ""
if IsValidArray(arrPageTitles
) then
strTestTitles = Join(arrPageTitles,"")
'check to see if all titles are empty, then avoid displaying table of contents
if len(strTestTitles) > 0 then
strResult = "<p class=""TOCTitle"">" & _
"TABLE OF CONTENTS" & _
"</p> " & _
"<p>"
if arrPageTitles(iCurrentPgNu
m-1) = "" then
'current page does not have a TOC title, so we'll display find the index of the previous TOC item that did
for y = iCurrentPgNum - 1 to 0 step -1
if arrPageTitles(y) <> "" then
iActiveIndex = y
exit for
end if
next
else
'current page has TOC title, so we'll display it
iActiveIndex = iCurrentPgNum - 1
end if
for x = 0 to UBound(arrPageTitles)
if x = iActiveIndex then
strResult = strResult & _
"<span class=""TOCItem"" >" & arrPageTitles(x) & "</span> <br>" & vbCrLf
else
if arrPageTitles(x) <> "" then
strResult = strResult & _
"<a class=""TOCItem"" href=""javascript:SubmitFo
rm('JUMPTO
PAGE','" & x + 1 & "');"">" & arrPageTitles(x) & "</a> <br>" & vbCrLf
end if
end if
next
strResult = strResult & "</p>"
end if
if blnDebug then
AddToDebugString "strTestTitles=" & strTestTitles & "--", true
AddToDebugString "iActiveIndex=" & iActiveIndex, false
end if
end if
PopulateTableOfContents = strResult
end function
function LoadBodyPage(iPage)
on error resume next
dim strSQL, adoRS, strResult, x
strResult = ""
if strPreviewMode = "" then
if iArticleID <> "" then
strSQL = "SELECT PageTitle, Body FROM ART_ArticleBody WHERE ArticleID = " & iArticleID & " ORDER BY PageNum "
set adoRS = Server.CreateObject("ADODB
.Recordset
")
adoRS.CursorLocation = 3 'adUseClient
adoRS.Open strSQL, oConn
AddToDebugString "adoRS.Recordcount=" & adoRS.Recordcount - 1, false
x = 1
if adoRS.State = 1 then
Redim preserve arrPageTitles(adoRS.Record
count - 1)
while not (adoRS.EOF OR adoRS.BOF)
if x = cint(iPage) then
strResult = adoRS("Body")
end if
arrPageTitles(x-1) = adoRS("PageTitle")
x = x + 1
adoRS.movenext
wend
end if
if err.number <> 0 then
AddToDebugString "Error:LoadBodyPage(): " & err.number & " - " & err.Description, true
end if
if adoRS.state = 1 then
adoRS.close
end if
set adoRS = nothing
end if
if blnDebug then
AddToDebugString "strSQL=" & strSQL, true
AddToDebugString "iPage=" & iPage, false
end if
elseif strPreviewMode = "true" then
strResult = "<script language=javascript>" & _
"document.write(parent.doc
ument.form
1.elements
['txtBodyP
g" & iPage & "'].value);</script>"
end if
LoadBodyPage = strResult
end function
function WriteAuthorCredit()
dim strResult
strResult = ""
if strPreviewMode = "" then
if iCurrentPgNum = iTotalPgNum AND (strAuthor <> "" OR strCredit <> "") then
strResult = " <p><BR><BR>" & _
"<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=1>" & _
"<TR>"
if strAuthor <> "" then
strResult = strResult & "<TD align=right>Author:</TD>" & _
"<TD>" & strAuthor & "</TD>"
end if
if strCredit <> "" then
strResult = strResult & "<TD align=right>Credit:</TD>" & _
"<TD>" & strCredit & "</TD>"
end if
strResult = strResult & "</TR>" & _
"</TABLE>" & _
"</p>"
end if
elseif strPreviewMode = "true" AND iCurrentPgNum = iTotalPgNum then
strResult = " <p><BR><BR>" & _
"<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=1>" & _
"<TR>" & _
"<TD align=right>Author:</TD>" & _
"<TD><script language=javascript>docume
nt.write(p
arent.docu
ment.form1
.txtAuthor
.value);</
script></T
D>" & _
"<TD align=right>Credit:</TD>" & _
"<TD><script language=javascript>docume
nt.write(p
arent.docu
ment.form1
.txtCredit
.value);</
script></T
D>" & _
"</TR>" & _
"</TABLE>" & _
"</p>"
end if
WriteAuthorCredit = strResult
end function
%>