<SCRIPT LANGUAGE="vbscript" RUNAT="Server">
rem Define Carriage Return/Line Feed
CRLF = Chr(13) & Chr(10)

rem Generate FDF header data
sub FDFHeader()
   response.ContentType = "application/vnd.fdf"
   'response.ContentType = "text/html"
   response.write("%FDF-1.2" & CRLF)
   response.write("1 0 obj <<" & CRLF)
   response.write("/FDF <<" & CRLF)
   response.write("/Fields" & CRLF)
   response.write("[" & CRLF)
end sub

rem Generate FDF footer data
sub FDFFooter ( pdfFile)
   response.write("]" & CRLF)
   response.write(">>" & CRLF)
   response.write(">>" & CRLF)
   response.write("endobj" & CRLF)
   response.write("trailer" & CRLF)
   response.write("<</Root 1 0 R>>" & CRLF)
   response.write ("%%EOF")
end sub

rem Generate FDF name/value pair
sub FDFValue (fdf_name, fdf_value)
   response.write("<<" & CRLF)
   response.write("/T (" & fdf_name & ") " & CRLF)
   response.write("/V (" & fdf_value & ") " & CRLF)
   response.write(">>" & CRLF)
end sub

' declare variables
Dim title

' set the var equal to the value of the field
title = Request.Form("wftitle")

' create Cookie
Response.Cookies ("ttwftitle") = title
Response.Cookies ("ttwftitle").Domain = "greggriffiths.org"
Response.Cookies ("ttwftitle").Path = "/"

' send back a response to trigger the actual submit
FDFHeader()
call FDFValue("flagfield", "1")
FDFFooter (request.servervariables("HTTP_REFERER"))
</script>