%@ Language = "VBScript"%>
<%
Response.Buffer = True
%>
<%
const adNew = 1
const adLive = 2
const adRejected = 3
const adHold = 4
const adAll = 5
const adEditView = 1
const adSuccessMsgView = 2
const adPreView = 3
Dim X
Dim blnTitleErr, blnStoryDateErr, blnStoryTextErr, blnFirstNameErr, blnLastInitialErr, blnAgeErr, blnStateErr
Dim blnoptionErr, javaasp, aspSJScript, aspSHeader, aspsFooter
'----------------------------------------------------------------------
'Purpose: converts 2 single quotes ('') to "
'Input: strQuote - string with double quotes
'----------------------------------------------------------------------
Function ConvSingleQ (strQuote)
If InStr (strQuote,"''") Then
ConvSingleQ = Replace (strQuote, "''", """")
Else
ConvSingleQ = strQuote
End If
End Function
'----------------------------------------------------------------------
'Purpose: converts " to 2 single quotes ('') in order to assign
' to the value attribute of a field
'Input: strQuote - string with double quotes
'----------------------------------------------------------------------
Function ConvDoubleQ (strQuote)
If InStr (strQuote,"""") Then
ConvDoubleQ = Replace (strQuote, """", "''")
Else
ConvDoubleQ = strQuote
End If
End Function
Function FirstLetterUpper (strToConvert)
If strToConvert <> "" Then
FirstLetterUpper = UCase(Left(strToConvert,1)) & right(strToConvert, Len(strToConvert) - 1)
End If
End Function
Sub InsertSubmission
Dim cnnImm, strSQL, rs
Set rs = Server.CreateObject("ADODB.Recordset")
'strSQL = "select ID, Hold, Status, Writing_Title, Imm_Country, Story_Text, Firstname, LastInitial, Age, Schoolname, State, EntryDate FROM CB_Trailblazers" --->Sanjay
'strSQL = "select ID, Hold, Status, Writing_Title, Imm_Country, Story_Text, Firstname, LastInitial, Age, State, EntryDate FROM CB_Trailblazers"
strSQL = "select * FROM " & TABLE_name
rs.Open strSQL, CONNECTION_STRING, 1, 3
rs.AddNew
rs("Q1") = strHtmTitle
rs("Q2") = strHtmStoryDate
rs("Q3") = strHtmStoryText
rs("Firstname") = strHtmFirstname
rs("LastInitial") = strHtmLastInitial
rs("Age") = FormatTextHTML(request("Age"))
rs("WritingType") = FormatTextHTML(request("WritingType"))
rs("EntryDate") = Now()
rs("State") = FormatTextHTML(request("State"))
rs("Status") = 1
rs.Update
rs.Close
set rs = Nothing
End Sub
Dim strDisplayMonth, strDisplayDay, strDisplayYear
Dim strMonth, strDay, strYear
strDisplayMonth = "Month"
strDisplayDay = "Day"
strDisplayYear = "Year"
strMonth = FormatTextHTML(request("Month")) 'drop down
strDay = FormatTextHTML(request("Day")) 'drop down
strYear = FormatTextHTML(request("Year")) 'drop down
Dim strStoryDate
strStoryDate = strMonth & "/" & strDay & "/" & strYear
'convert form entry to html, catch special characters & preserve correct format
dim strHtmTitle
strHtmTitle = Trim(FormatTextHTML(request("Story_Title")))
strHtmTitle = FormatTextHTML(strHtmTitle)
dim strHtmStoryDate
strHtmStoryDate = Trim(strStoryDate)
strHtmStoryDate = FormatTextHTML(strHtmStoryDate)
dim strHtmStoryText
strHtmStoryText = Trim(FormatTextHTML(request("Story_Text")))
strHtmStoryText = FormatTextHTML(strHtmStoryText)
dim strHtmFirstname
strHtmFirstname = Trim(FormatTextHTML(request("Firstname")))
strHtmFirstname = FormatTextHTML(strHtmFirstname)
dim strHtmLastInitial
strHtmLastInitial = Trim(FormatTextHTML(request("LastInitial")))
strHtmLastInitial = FormatTextHTML(strHtmLastInitial)
'convert form entry to text, catch special characters & preserve correct format
dim strTxtTitle
strTxtTitle = Trim(FormatTextHTML(request("Story_Title")))
strTxtTitle = FormatHTMLText(strTxtTitle)
dim strTxtStoryDate
strTxtStoryDate = Trim(strStoryDate)
strTxtStoryDate = FormatTextHTML(strTxtStoryDate)
dim strTxtStoryText
strTxtStoryText = Trim(FormatTextHTML(request("Story_Text")))
strTxtStoryText = FormatHTMLText(strTxtStoryText)
dim strTxtFirstname
strTxtFirstname = Trim(FormatTextHTML(request("Firstname")))
strTxtFirstname = FormatHTMLText(strTxtFirstname)
dim strTxtLastInitial
strTxtLastInitial = Trim(FormatTextHTML(request("LastInitial")))
strTxtLastInitial = FormatHTMLText(strTxtLastInitial)
Dim aStates, aAges, blnFormOK, blnValidateForm
aStates = Array( "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", _
"Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", _
"Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", _
"Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", _
"Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", _
"New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", _
"Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", _
"South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", _
"West Virginia", "Wisconsin", "Wyoming", "------------", _
"Afghanistan", "Albania ", "Algeria ", "Andorra ", "Angola", "Antigua/Barbuda", "Argentina", _
"Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", _
"Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia/Herzegovina", "Botswana", _
"Brazil", "Brunei", "Bulgaria", "Burkina faso", "Burundi", "Cambodia", "Cameroon", "Canada", _
"Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo Republic", _
"Costa Rica", "Cote d Ivore", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", _
"Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", _
"Estonia", "Ethiopia", "Fiji", "Finland", "France", "French Guiana", "Gabon", "Gambia", "Georgia", _
"Germany", "Ghana", "Greece", "Grenada", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", _
"Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", _
"Italy", "Jamaica", "Japan", "Jordan", "Kazakstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos", _
"Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", _
"Macedonia", "Madagascar", "Malawi", "Malaysia", "Mali", "Malta", "Marshall Islands", "Mauritania", _
"Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", _
"Namibia", "Nepal", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "North Korea", _
"Norway", "Oman", "Pakistan", "Palau", "Panama", "Papau New Guinea", "Paraguay", "Peru", "Philippines", _
"Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Samoa", "Sao Tome and Principe", _
"Saudi Arabia", "Senegal", "Sierra-Leone", "Slovakia","Slovenia", "Solomon Islands", "Somalia", "South Africa", _
"South Korea", "Spain", "Sri Lanka", "St Kitts/Nevis", "St Lucia", "St Vincent/The Grenadines", "Sudan", _
"Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Tahiti", "Taiwan", "Tajikistan", "Tanzania", _
"Thailand", "The Netherlands", "Togo", "Tonga", "Trinidad/Tobago", "Tunisia", "Turkey", "Turkmenistan", _
"Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "Uruguay", "Uzbekistan", "Vanuatu", _
"Venezuela", "Vietnam", "Virgin Islands", "Western Sahara", "Yemen", "Yugoslavia", "Zambia", "Zimbabwe" )
Dim oldViewMode, curViewMode
oldViewMode = FormatTextHTML(request.Form("ViewMode"))
'********** Check Mode ***********
select Case FormatTextHTML(request("FormAction"))
Case "Preview":
curViewMode = adPreView
blnValidateForm = True
Case "Submit", "Edit":
If oldViewMode = adPreView Then ' if form has been already validated
blnValidateForm = False
Else
blnValidateForm = True
End If
curViewMode = adEditView
Case Else:
curViewMode = adEditView
blnValidateForm = False
End select
'********** Validating Form ***********
If blnValidateForm <> False then
Dim strErrorFields
strErrorFields = ""
If FormatTextHTML(request("Story_Title")) = "" then
strErrorFields = "Title"
blnTitleErr = True ' -->Sanjay
End If
If ( ( strMonth = "" ) or ( strDay = "" ) or ( strYear = "" ) or ( Not IsDate(strStoryDate) ) ) Then
If strErrorFields <> "" then strErrorFields = strErrorFields & ", "
blnStoryDateErr = True
strErrorFields = strErrorFields & "Story Date"
If strMonth = "" Then
strDisplayMonth = "Month"
Else
strDisplayMonth = strMonth
End If
If strDay = "" Then
strDisplayDay = "Day"
Else
strDisplayDay = strDay
End If
If strYear = "" Then
strDisplayYear = "Year"
Else
strDisplayYear = strYear
End If
Else
If strMonth = "" Then
strDisplayMonth = "Month"
Else
strDisplayMonth = strMonth
End If
If strDay = "" Then
strDisplayDay = "Day"
Else
strDisplayDay = strDay
End If
If strYear = "" Then
strDisplayYear = "Year"
Else
strDisplayYear = strYear
End If
End If
If FormatTextHTML(request("Story_Text")) = "" then
If strErrorFields <> "" then strErrorFields = strErrorFields & ", "
strErrorFields = strErrorFields & "News Story"
blnStoryTextErr = True
End If
If FormatTextHTML(request("Firstname")) = "" then
If strErrorFields <> "" then strErrorFields = strErrorFields & ", "
strErrorFields = strErrorFields & "First Name"
blnFirstNameErr = True
End If
'Making Last Initial Field Mandatory ---->Sanjay
If FormatTextHTML(request("LastInitial")) = "" then
If strErrorFields <> "" then strErrorFields = strErrorFields & ", "
strErrorFields = strErrorFields & "Last Initial"
blnLastInitialErr = True
End If
'Code addition ended
If FormatTextHTML(request("Age")) = "0" then
If strErrorFields <> "" then strErrorFields = strErrorFields & ", "
strErrorFields = strErrorFields & "Age"
blnAgeErr = True
End If
If FormatTextHTML(request("State")) = "0" Or FormatTextHTML(request("State")) = "------------" then
If strErrorFields <> "" then strErrorFields = strErrorFields & ", "
strErrorFields = strErrorFields & "State"
blnStateErr = True
End If
If strErrorFields = "" then ' Any Error?
blnFormOK = True ' No Error
Else
blnFormOK = False ' At least one Error
End If
End If
dim strVar
strVar = FormatTextHTML(request("FormAction"))
'********** Save/Update Record ***********
If blnFormOK AND strVar = "Submit" Then
curViewMode = adSuccessMsgView
InsertSubmission
'else
'Response.Write "blnFormOK: " & blnFormOK & "
"
'Response.Write "adSuccessMsgView:" & adSuccessMsgView & "
"
'Response.Write "FormAction: " & strVar & "
"
'Response.Write "curViewMode: " & curViewMode & "
"
'Response.Write "error: " & err.description
'response.write "Error Number= #" & err.number & "
"
'response.write "Error Desc.= " & err.description & "
"
'response.write "Help Context= " & err.HelpContext & "
"
'response.write "Help File Path=" & err.helpfile & "
"
'response.write "Error Source= " & err.source & "
|
<% select Case curViewMode Case adEditView: ' Edit/Error Fix If strErrorFields <> "" then ' Error Found? ' YES, there is some error Response.Write " Oops! " Response.Write " You need to include information in every field in order for us to post your article in The Earhart Gazette. " Response.Write "Please fill in the following fields: " & strErrorFields & ". " End If %>Have you done all your research? Is your story historically accurate? Have you checked your work for spelling and grammatical errors? Have you written, and read, and rewritten and reread, until it's exactly as you want it? We hope so, because we're on deadline here at The Earhart Gazette, and it's time to turn in your story! Please read our Terms of Submission before you submit any work. All Fields are Required for us to post your story
THANK YOU! Thank you for contributing to The Earhart Gazette. Your story will be reviewed by Scholastic to see if it fulfills the requirements of the project. If it does, it will be posted online in a few days. Please feel free to submit another story at any time. <% Case adPreView: %>
Kids: Ask your parents or teachers for approval before you submit anything to us, and read our Privacy Policy Statement. Before being published, your submission will be reviewed. It will be checked to see that it does not contain any inappropriate language. By sending us your work, you are giving Scholastic permission to edit, promote, and put it up on Scholastic.com. However, because lots of students send us work, we won't be able to publish all of the work that we receive. Also, it is really important to send us only work that you made from scratch and not any work that you copied from somewhere else. Thank you. <% End Select %> |