date validation: UNDER A DEADLINE, Please help (1 Viewer)

dbertanjoli

Registered User.
Local time
Today, 01:32
Joined
Sep 22, 2000
Messages
102
I have a webform (it is designed the way that administrator can add questions on line), but this form doesn't have any setting for date (date validation). So, in my access database I added a new question category called OPEN4 which I would like to use for dates.

I am attaching the whole page but date validation should be applied to OPEN4 (please see below). I am undear a deadline and would greatly appreciate any help.

p.s. I am not very familiar with asp, please be specific. Debbie

Can I and how use these lines:
document.write(IsDate("April 22, 1947") & "<br />")
document.write(IsDate(#11/11/01#) & "<br />")
document.write(IsDate("#11/11/01#") & "<br />")
document.write(IsDate("Hello World!"))

In this code (Case "OPEN4") I would greatly appreciate any reply. Debbie
_____________________________

Case "OPEN4"
Response.Write " <INPUT TYPE='text' NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "' " &_
"SIZE=40 MAXLENGTH='" & iOPEN2MAXLENGTH & "' VALUE=""" &_
OutTextBoxText(Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))) & """>"

_____________________________________________________________________________------

This is the whole page

<% option explicit
' OurWebSurvey.
' All code is strictly copyright of Visualize Systems Ltd, UK, 2002-present.
%>
<!--#include file="include\checklogin.inc"-->
<!--#include file="include\setup.inc"-->
<!--#include file="include\locHTMLcontrols.inc"-->
<!--#include file="include\WebApp.inc"-->
<!--#include file="include\error2.inc"-->
<!--#include file="include\PageNoFuncs.inc"-->
<!--#include file="include\GenerateKey.inc"-->
<!--#include file="include\DAL\CatDAL.inc"-->
<!--#include file="include\DAL\PageDAL.inc"-->
<!--#include file="include\DAL\QDAL.inc"-->
<!--#include file="include\DAL\SurveyDAL.inc"-->
<!--#include file="include\DAL\DBExec.inc"-->
<!--#INCLUDE file="include\ParsFld.inc"-->
<!--#INCLUDE file="include\GetBasicSurveyInfo.inc"-->
<!--#INCLUDE file="include\outheader.inc"-->
<!--#INCLUDE file="include\DAL\dbutils.inc"-->
<!--#include file="include\datelib.inc"-->
<!--#include file="include\datelib.inc"-->
<!--#INCLUDE file="include\checkfield.inc"-->
<%
'*****************************************************
'* Start of main routine *
'*****************************************************
' script level vars
Dim oDBConn, oDictQs, rsQuest, rsChoice, rsScale, bDesignMode, iPageNo, sAction, sCurrentQStyle
Dim sStatusMsg, sName, iSurveyID, iClientID, sSurveyKey

' create objects
Set oDBConn = Server.CreateObject("ADODB.Connection")
oDBConn.Open sDBCONNSTR
Set oDictQs = CreateObject("Scripting.Dictionary")

if request.querystring("sid") <> "" then
session("formsubmitted") = "NO" ' first time in
end if
iClientID=session("loginclientid")
iSurveyID = request.querystring("sid") & request.form("hidSurveyID")
sSurveyKey = request.querystring("k") & request.form("hidSurveyKey")
Call GetBasicSurveyInfo(iSurveyID,sSurveyKey) ' get header etc for this survey

iPageNo = request.querystring("p") & request.form("hidPageNo") ' pick up from GET OR from a POST
if Not IsNumeric(iPageNo) or iPageNo = "" or iPageNo = "0" then
iPageNo = GetPageNoMinMax(oDBConn,"min")
else
iPageNo = Cint(iPageNo)
end if

' Is the page being called in design mode or user mode
If (Request.Form("hidDesignMode") = "yes") or (Request.Querystring("DesignMode") = "yes") Then
bDesignMode = True
Else
bDesignMode = False
End If

sAction = request.form("butAction")
select case sAction
case "Next Page >>"
If FormIsValid() Then
iPageNo = iPageNo + 1
Call DisplayQuestionnaire(true)
else
Call DisplayQuestionnaire(false)
end if
case "<< Previous Page"
iPageNo = iPageNo - 1
Call DisplayQuestionnaire(true)
case "Submit Questionnaire"
If FormIsValid() Then
if (session("formsubmitted") <> "YES") OR bALLOWMULTISUBMITS then
Call WriteResultsToDB() ' all valid data, so take data and write to results DB
end if
call Outheader("Survey Submitted")
Response.Write "<TABLE BORDER='0' CELLSPACING='5' WIDTH='85%' class='Questions' align='center'>"
Response.Write "<tr><td colspan='3'>"
response.write DBLookUpDescription(oDBConn, iSurveyID, "owssurvey", "SurveyID", "SurveySubmittedText")
Response.Write "</td></tr></table>"
session("formsubmitted") = "YES" ' stops submitting twice
Else
Call DisplayQuestionnaire(false)
End If
case else
if request.querystring("rencat")="yes" then
call CatDALRenumberCats(oDBConn)
sStatusMsg = "Categories re-numbered"
end if
if request.querystring("renpage")="yes" then
call RenumberPages(oDBConn)
sStatusMsg = "Pages re-numbered"
iPageNo = 1
end if
Call DisplayQuestionnaire(true) ' produce empty questionnaire based on database meta data
End select

Call CloseAll() ' close and destroy all objects


'*********** End of main routine **********************


'*****************************************************
'* Local procedures/functions *
'*****************************************************

Private Sub DoQuery()
' Generates SQL to pull back all question meta data
' and runs query against DB
set rsQuest = QDALGetMetaData()
End Sub

'*****************************************************

Private Function FormIsValid()
' Validates form data entered, against meta data in database
' Sets up oDictQs with question nos expected to be answered.
' RETURN VALUE: True if all is OK, otherwise FALSE

Dim sItem, sCheckBox, bValid, iPos, sCatQuest, sOPEN3Key, iOPEN3Value

set rsQuest = QDALGetQuestionsForPage()

' fill dict obj with form items posted (Key=Qx-x, Data=OK)
sCheckBox = ""
bValid = True
For Each sItem in Request.Form
if (left(sItem,3) <> "but") And (Request.Form(sItem) <> "") then ' Ignore the submit button or empty fields

iPos = InStr(1,sItem,"_chk",1) ' Check for check box multi-choice
If (iPos) Then ' If so, then add only the Question No (not all the boxes)
sCatQuest = CStr(mid(sItem,1,iPos-1))
Else
sCatQuest = CStr(sItem)
End If

If (Not oDictQs.Exists(sCatQuest)) Then ' If CatQuestion not already added, then add it
oDictQs.Add sCatQuest, Request.form(sItem)
End If
End If
Next

' now check definitive metabase Question nos against dictionary list
Do While (NOT rsQuest.EOF)
If (Not oDictQs.Exists(CStr("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")))) AND _
(rsQuest("mandatory") = "Y") then
oDictQs.Add CStr("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")), "QGENFIELDERR:This field must be entered" ' not found and mandatory, so mark as in error
bValid = False
else
' OPEN3 is numeric with a range
if rsQuest("QuestionTypeID") = "OPEN3" then
sOPEN3key=CStr("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))
iOPEN3Value=oDictQs.item(sOPEN3key)

if NOT Isnumeric(iOPEN3Value) then
oDictQs.remove sOPEN3key
oDictQs.add sOPEN3key, "QGENFIELDERR:This should be numeric"
bValid = False
else
if (CLng(iOPEN3Value) > Clng(rsQuest("MaxValue")) AND iOPEN3Value<>"") OR _
(CLng(iOPEN3Value) < Clng(rsQuest("MinValue")) AND iOPEN3Value<>"") then
oDictQs.remove CStr("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))
oDictQs.add CStr("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")), "QGENFIELDERR:This is not in the correct range" ' range err
bValid = False
end if
end if
end if
End If
rsQuest.MoveNext
Loop

FormIsValid = bValid

End Function

'*****************************************************
Private Function ValidDateDDMMM(sDDMMM)
' checks DDMMM date (no year, eg birthday) and simply checks to see if a valid "date"
' Return TRUE if valid, else FALSE
dim sDD, sMMM,bReturnValue

sDD = UCASE(left(sDDMMM,2))
sMMM = UCASE(right(sDDMMM,3))
bReturnValue=true

Select Case sDD
Case 31
if InStr(1,"JAN,MAR,MAY,JUL,AUG,OCT,DEC",sMMM) <= 0 then
bReturnValue=false
end if
Case 30
if sMMM = "FEB" then
bReturnValue=false
end if
end select

ValidDateDDMMM=bReturnValue

end function
'*****************************************************

Private Sub DisplayQuestionnaire(bValid)
' Display the questionnaire, using metabase information

Dim bQuestEOF, bSameCategory, iOldCategoryNo, iOldQuestionNo, bPagePreamble, sFooterText, iLastCategoryNo, iLastQuestionNo
Call DoQuery()

if bDesignMode then
call Outheader("edit questionnaire")
else
call Outheader(sSurveyTitle)
end if

Response.Write "<DIV ALIGN='CENTER'>"
Response.write "<FORM NAME='frmQuest' ACTION='q.asp' METHOD='POST'>"
response.write "<input type='hidden' name='hidSurveyID' value='" & iSurveyID & "'>"
response.write "<input type='hidden' name='hidSurveykey' value=""" & sSurveyKey & """>"
response.write "<input type='hidden' name='hidPageNo' value='" & iPageNo & "'>"
Response.Write "<TABLE BORDER='0' CELLSPACING='5' WIDTH='95%' class='Questions'>"
if not bDesignMode and request.querystring("designmode") <> "preview" then
' hit response count limit or end date reached ?
if (Clng(iSurveyRespCount) > Clng(iSurveyMaxResp)) OR _
(datSurveyEndDate < date()) then
Response.Write "<tr><td colspan='3'>"
Response.Write "<P>"
response.write DBLookUpDescription(oDBConn, iSurveyID, "owssurvey", "SurveyID", "SurveyOverText")
Response.Write "</P>"
Response.Write "</td></tr></table>"
exit sub
end if
end if

' now handle status of survey (ie design mode, trial, live and closed)
select case sSurveyPublishID
case "N"
if not bDesignMode and request.querystring("designmode") <> "preview" then ' user cannot submit whilst design mode
Response.Write "<tr><td colspan='3'>"
Response.Write "<P>This survey is presently unavailable (it may not yet have been published).</P>"
Response.Write "</td></tr></table>"
exit sub
end if
case "C"
Response.Write "<tr><td colspan='3'>"
Response.Write "<p>"
response.write DBLookUpDescription(oDBConn, iSurveyID, "owssurvey", "SurveyID", "SurveyOverText")
Response.Write "</p></td></tr></table>"
exit sub
case else
' do nothing
end select

If bDesignMode Then
response.write "<tr><td colspan='3' class='QDesignerMenu' align='center'><a href='q.asp?sid=" & iSurveyID & "&k=" & sSurveykey & "&p=" & iPageNo & "&designmode=preview' target='new_window' title='preview this page in a new window'>Preview Page</A> | <a href='q.asp?sid=" & iSurveyID & "&k=" & sSurveykey & "&designmode=yes&renpage=yes' title='re-order page numbers consecutively'>Re-order Page Numbers</A> | <a href='q.asp?sid=" & iSurveyID & "&k=" & sSurveykey & "&designmode=yes&rencat=yes' title='re-order category numbers consecutively'>Re-order Category Numbers by Page</A> | <a href='usurvey.asp?m=u&sid=" & iSurveyID & "&k=" & sSurveykey & "' title='back to survey summary'>Survey Summary</A> | <a href='cp.asp' title='back to survey list'>Survey List</A></td></tr>"
response.write "<tr><td colspan='3' align='center'>"
response.write " </td></tr>"
end if

if bDesignMode or sSurveyShowProgressBar = "Y" then
response.write "<tr><td colspan='3' align='center'>"
call OutProgressBar(iPageNo)
response.write " </td></tr>"
end if

If (NOT bvalid) Then
response.write "<tr><td colspan='3'>"
Response.Write "<span class='StatusMessageErr'>You have not filled in the form correctly. " &_
"Please check the questions marked with an asterisk</span> <span class='ErrorAsterisk'>*</span>"
response.write " </td></tr>"
End If

If bDesignMode Then
if sStatusMsg <> "" then
response.write "<tr><td colspan='3' align='center'><span class='StatusMessage'>" & sStatusMsg & "</span></td></tr>"
end if
Response.Write "<TR>"
Response.Write "<TD COLSPAN='3' VALIGN='TOP' ALIGN='CENTER' class='QPageNo'>Page No: "
Response.write iPageNo
if iPageNo <> "" then
response.write " <input type='button' value=' Edit ' OnClick=""document.location.href='updPage.asp?sid=" & iSurveyID & "&k=" & sSurveykey & "&mode=update&p=" & iPageNo & "';"">"
end if
response.write " <input type='button' value=' Add ' OnClick=""document.location.href='updPage.asp?sid=" & iSurveyID & "&k=" & sSurveykey & "&mode=add&p=" & iPageNo & "';"">" &_
"<TD></TR>"
end if

bPagePreamble=false
iLastCategoryNo=0
Do While (NOT rsQuest.EOF)
if Cint(rsQuest("pageno")) = Cint(iPageNo) then
if bPagePreamble = false then
Response.Write "<TR>"
Response.Write "<TD COLSPAN='3' ALIGN='LEFT' BGCOLOR='WHITE'>"
Response.Write rsQuest("preamble") & "<br> "
response.write "</TD></TR>"
bPagePreamble=true
sFooterText = rsQuest("footertext")
end if
bSameCategory = True
if Not Isnull(rsQuest("CategoryNo")) then
Response.Write "<TR>"
Response.Write "<TD COLSPAN='3' class='QCategory'>"
If bDesignMode Then
Response.Write "<A HREF='updCat.asp?sid=" & iSurveyID & "&k=" & sSurveykey & "&mode=update&C=" & rsQuest("CategoryNo") & "'>" &_
rsQuest("CategoryNo") & ". " & rsQuest("CategoryDesc") & "</A>"
Else
Response.Write rsQuest("CategoryNo") & ". " & rsQuest("CategoryDesc")
End If
Response.write "</TD></TR>"
end if

Response.Write "<TR>"
Response.Write "<TD COLSPAN='3' ALIGN='LEFT'>" & OutTextAsHTML(rsQuest("categorysummary")&"")
response.write "<TD></TR>"

iLastQuestionNo=0
bQuestEOF = False
sCurrentQStyle = "QLine1" ' alternate colours between question lines for readability
Do While (NOT bQuestEOF) And (bSameCategory)
If NOT IsNull(rsQuest("QuestionNo")) Then
Response.Write "<TR>"
Response.Write "<TD VALIGN='top' class='" & sCurrentQStyle & "'>" & rsQuest("CategoryNo") & "." & rsQuest("QuestionNo")
If left(oDictQs.Item(Cstr("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))),12) = "QGENFIELDERR" Then
Response.Write " <span class='ErrorAsterisk'>*</span>"
else
if rsQuest("mandatory") = "Y" then
Response.Write " <span class='MandatoryAsterisk'>*</span>"
end if
End If
Response.Write "</TD>"

If bDesignMode Then
Response.Write "<TD VALIGN='top' class='" & sCurrentQStyle & "'><A HREF='updQ.asp?sid=" & iSurveyID & "&k=" & sSurveykey & "&mode=update&p=" & iPageNo & "&c=" &_
rsQuest("CategoryNo") & "&Q=" & rsQuest("QuestionNo") & "'>" &_
rsQuest("Description") & "</A>"
Else
Response.Write "<TD VALIGN='top' class='" & sCurrentQStyle & "'>" & rsQuest("Description")
End If

Response.Write "</TD>"
Response.Write "<TD class='" & sCurrentQStyle & "'>"
' now display question type (eg scale, open, multi-choice)
Call OutQuestionType()

' output field validation error text (if any)
If left(oDictQs.Item(Cstr("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))),12) = "QGENFIELDERR" Then
Response.Write "  <span class='FieldErrorText'>" & Mid(oDictQs.Item(Cstr("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))),14) & "</span>"
end if

Response.Write "</TD>"
Response.Write "</TR>"
iOldQuestionNo = rsQuest("QuestionNo")
iLastQuestionNo = iOldQuestionNo
Else
iOldQuestionNo = 0
End If

iOldCategoryNo = rsQuest("CategoryNo")
if isnull(iOldCategoryNo) then
iOldCategoryNo=0
end if
if not isnull(iOldCategoryNo) then
iLastCategoryNo=iOldcategoryNo
end if
rsQuest.MoveNext
bQuestEOF = rsQuest.EOF
If NOT bQuestEOF Then
If (CStr(iOldCategoryNo) <> CStr(rsQuest("CategoryNo")&"")) or (Cint(rsQuest("pageno")) <> cint(iPageNo)) then
bSameCategory = False
else
if sCurrentQStyle = "QLine1" then
sCurrentQStyle = "QLine2"
else
sCurrentQStyle = "QLine1"
end if
End IF
End If
Loop

If bDesignMode and CLng(iLastCategoryNo) > 0 Then
Response.Write "<TR>"
Response.Write "<TD width='5%'> </TD>"
Response.Write "<TD COLSPAN=2 ALIGN=RIGHT><A HREF='updQ.asp?sid=" & iSurveyID & "&k=" & sSurveykey & "&mode=add&C=" &_
Clng(iLastCategoryNo) & "&Q=" & CStr(Clng(iLastQuestionNo) + 1) &_
"&p=" & iPageNo & "'><B><I>add new question</A> </TD>"
Response.Write "</TR>"
else
Response.Write "<TR><td colspan='3'> </td></tr>"
End If
else
' not current page so need to create a hidden field for fields on other pages
' Only applies to non-design mode and pages with a question on it!
if (not bDesignMode) and (not IsNull(rsQuest("QuestionNo"))) then
if rsQuest("QuestionTypeID") = "MULTICHOICE" then
Call GetChoices(rsQuest("questionid")) ' obtain all choices for this question
Call OutMultiChoiceHidden()
else
Response.Write "<INPUT TYPE='hidden' NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "'" &_
" VALUE=""" &_
OutTextBoxText(Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))) & """>"
end if
end if
rsQuest.MoveNext
end if
Loop

If bDesignMode Then
if iPageNo <> "" then
Response.Write "<TR>"
Response.Write "<TD COLSPAN=3 class='QCategory' ALIGN=RIGHT> <A HREF='updCat.asp?sid=" & CLng(iSurveyID) & "&k=" & sSurveykey & "&mode=add&" &_
"C=" & CStr(Clng(iLastCategoryNo)+1) & "&p=" & CLng(iPageNo) & "'>" &_
"<B><I>add new category</A> "
Response.Write "</TD></TR>"
end if

Response.Write "<TR><TD COLSPAN=3 class='QCategory'> </TD></TR>"
Response.Write "<TR><TD COLSPAN=3> <BR>" & sFooterText & "<BR> </TD></TR>"
Else
Response.Write "<TR><TD COLSPAN=3 class='QCategory'> </TD></TR>"
Response.Write "<TR><TD COLSPAN=3> <BR>" & sFooterText & "<BR> </TD></TR>"
Response.Write "<TR><TD COLSPAN=3 ALIGN=CENTER>"
Call OutPrevNextPage()
response.write "</TD></TR>"
End If

Response.Write "</TABLE></FORM><P>"
response.write "</DIV>"

End Sub

'*****************************************************

Private Sub OutQuestionType()
' depending on question type for current question,
' outputs the appropriate form controls

Select Case rsQuest("QuestionTypeID")
Case "MULTICHOICE"
' Call GetChoices(rsQuest("CategoryNo"), rsQuest("QuestionNo")) ' obtain all choices for this question
Call GetChoices(rsQuest("questionid")) ' obtain all choices for this question
Call OutMultiChoice()

Case "OPEN1"
Response.Write " <TEXTAREA NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "' " &_
"COLS='50' ROWS='5' WRAP='virtual'>" &_
Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")) & "</TEXTAREA>"
Case "OPEN2"
Response.Write " <INPUT TYPE='text' NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "' " &_
"SIZE=40 MAXLENGTH='" & iOPEN2MAXLENGTH & "' VALUE=""" &_
OutTextBoxText(Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))) & """>"

Case "OPEN4"
Response.Write " <INPUT TYPE='text' NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "' " &_
"SIZE=40 MAXLENGTH='" & iOPEN2MAXLENGTH & "' VALUE=""" &_
OutTextBoxText(Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))) & """>"


Case "OPEN3"
Response.Write " <INPUT TYPE='text' NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "' " &_
"SIZE=10 MAXLENGTH='" & iOPEN3MAXLENGTH & "' VALUE=""" &_
OutTextBoxText(Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"))) & """> " &_
"<span class='OptionFieldText'>(value between " &_
rsQuest("MinValue") & " and " & rsQuest("MaxValue") & ")</span>"
Case "YESNO"
call OutRadioButton("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"), "Y", _
Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")), _
"<span class='OptionFieldText'>Yes" & "</span> ")
call OutRadioButton("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"), "N", _
Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")), _
"<span class='OptionFieldText'>No" & "</span> ")
Case "YESNO2"
call OutRadioButton("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"), "Y", _
Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")), _
"<span class='OptionFieldText'>Yes" & "</span> ")
call OutRadioButton("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"), "N", _
Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")), _
"<span class='OptionFieldText'>No" & "</span> ")
call OutRadioButton("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo"), "DK", _
Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")), _
"<span class='OptionFieldText'>Don't know" & "</span> ")
Case "UNIQUERADIO"
Call GetChoices(rsQuest("QuestionID")) ' obtain all choices for this question
Call OutUniqueRadio(Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")))

Case "UNIQUEDROPDOWN"
Call GetChoices(rsQuest("QuestionID")) ' obtain all choices for this question
Call OutUniqueDropDown(Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")))

Case Else
If Left(rsQuest("QuestionTypeID"),5) = "SCALE" Then
Call OutScale(rsQuest("QuestionTypeID"), Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo")))
Else
Response.write "Error: Unrecognised question type: " & rsQuest("CategoryNo") & "-" & rsQuest("QuestionTypeID")
End If
End Select

End Sub

'*****************************************************

Private Sub GetChoices(iQuestionID)
' obtains all choices from Choice table, for current question
set rsChoice = QDALGetChoices(iQuestionID)
End Sub

'*****************************************************

Private Sub OutUniqueDropDown(sSelectedValue)
' Creates a drop-down list of choices from rsChoice

Response.Write "<TABLE ALIGN='left' class='" & sCurrentQStyle & "' BORDER='0'><TR><TD>"
Response.write "<SELECT NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "'>"

Response.write "<OPTION VALUE=''>(please select)</OPTION>"
Do While NOT rsChoice.EOF
Response.write "<OPTION VALUE=""" & OutTextBoxText(rsChoice("ChoiceValue")) & """"

If rsChoice("ChoiceValue") = sSelectedValue Then 'default item in list ?
Response.Write " SELECTED"
End If

Response.write ">" & rsChoice("ChoiceDesc") & "</OPTION>"
rsChoice.MoveNext
Loop
Response.write "</SELECT>"
Response.Write "</TD></TR></TABLE>"

End Sub

'*****************************************************

Private Sub OutUniqueRadio(sSelectedValue)
' Creates a list of radio buttons based on rsChoice

Response.Write "<TABLE class='" & sCurrentQStyle & "'><TR><TD>"

Do While NOT rsChoice.EOF
Response.write "<INPUT TYPE='RADIO' NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") &_
"' VALUE=""" & OutTextBoxText(rsChoice("ChoiceValue")) & """ "

If rsChoice("ChoiceValue") = sSelectedValue Then 'default item in list ?
Response.Write "CHECKED"
End If

Response.write ">"
Response.Write "<span class='OptionFieldText'>" & rsChoice("ChoiceDesc")
if rsQuest("layout") = "H" then ' horizontal layout?
response.write " </span>"
else
response.write "<br></span>" ' vertical
end if
rsChoice.MoveNext
Loop

Response.Write "</TD></TR></TABLE>"

End Sub

'*****************************************************

Private Sub OutMultiChoice()
' Creates a list of check boxes based on rsChoice
Dim iCount, iItems

Response.Write "<TABLE class='" & sCurrentQStyle & "'><TR><TD>"

iCount = 1
Do While NOT rsChoice.EOF
Response.write "<INPUT TYPE='CHECKBOX' NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "_chk" & iCount &_
"' VALUE='" & rsChoice("ChoiceValue") & "' "
'default item in list ?
If rsChoice("ChoiceValue") = Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "_chk" & iCount) Then
Response.Write "CHECKED"
End If

Response.write ">"
Response.Write "<span class='OptionFieldText'>" & rsChoice("ChoiceDesc")
if rsQuest("layout") = "H" then ' horizontal layout?
response.write "  </span>"
else
response.write "<br></span>" ' vertical
end if
rsChoice.MoveNext
iCount = iCount + 1
Loop

Response.Write "</TD></TR></TABLE>"

End Sub

'*****************************************************

Private Sub OutMultiChoiceHidden()
' Creates a list of hidden "check boxes" based on rsChoice
Dim iCount, iItems

iCount = 1
Do While NOT rsChoice.EOF
If rsChoice("ChoiceValue") = Request.Form("Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "_chk" & iCount) Then
Response.write "<INPUT TYPE='HIDDEN' NAME='Q" & rsQuest("CategoryNo") & "-" & rsQuest("QuestionNo") & "_chk" & iCount &_
"' VALUE=""" & OutTextBoxText(rsChoice("ChoiceValue")) & """>"
End If
rsChoice.MoveNext
iCount = iCount + 1
Loop

End Sub

and so on
 

Users who are viewing this thread

Top Bottom