Re-display information on form after clicking the Back button or How to set a cookie

I posted this topic in a Microsoft discussion group and the reply I got is to store the answers to the form using a cookie.

I searched the forum and found 2 ways to set a cookie, using @Function and JavaScript.

I tried the @Function ie, @sethttpheader(“Set-Cookie”,“”), but i cant get it to run properly. i also used the @gethttpheader(“User-Agent”).

I placed all these functions in an agent for the WebQueryOpen of the form.

Try to access the form at http://hrmdsurvey.energy.com.ph

Here is the text of the message that I posted in the Microsoft discussion site:

I created a web-based form using Domino Designer. The respondent should not leave any unanswered item on the form.

My problem is: how do i retain the information that was already entered by the respondent after he clicked on the back button? Lets say, the respondent missed one item. Then he clicked the Submit button. A box would pop out and say, go back to the form to put an answer to the item. then he would click the back button.

I would like for the form to still display the respondent’s answers after he clicked on the back button and not answer the form all over again.

I noticed that when i accomplish the form in some versions of IE (or Windows version?), and deliberately missed an item, then click the Back button, the form retains the answers. but in some IE (or Windows version?), the form is blank.

I am on Windows XP with IE 6.0.2800. Does the version of the IE make a difference? Is there a setting on IE that can be configured in order to display the information again after clicking Back?

THanks for the help.

Subject: Re-display information on form after clicking the Back button or How to set a cookie

  1. Why not do validations in javascript before submitting, and display your validation messages in either dialog boxes or hidden text which you make visible as necessary?

  2. @sethttpheader(“Set-Cookie”; “CookieName=value; expires=expdate”) is the correct syntax (the expire date is optional; I think it defaults to the end of the current session). Are you using this syntax?

  3. You mention using @gethttpheader(“user-agent”), but not @gethttpheader(“Cookie”).

Subject: validation with formula

the main problem (apart from refresh and lost input) with using validation on the server is that it pops up one field at a time. You can get round that by putting all the server-side validation in the last editable field on the form - for example

lkp:=@DbLookup(“”:“NoCache”;“”;“Admin”;“Configure”;1;[ReturnDocumentUniqueID]);

err:=@If( @IsError(lkp) & @IsNewDoc; “”; lkp=@Text(@DocumentUniqueID); “”; “please use the existing Configure page, there can be only one in each web site~” )

+@If( @IsNewDoc & @LowerCase(cfgEmail)=“learnintechnology@lancaster.ac.uk”; “”; cfgEmail=“”; “the site owner’s email address is required~”; @ValidateInternetAddress([Address821];cfgEmail)=“”; “”; “the site owner’s email: “+ @ValidateInternetAddress([Address821];cfgEmail)+”~” )

+@If( @Elements(cfgLinkURLs)=0 | (@Elements(cfgLinkURLs) = @Elements(cfgLinkTitles)); “”; “URLs and URL titles do not match~”);

@If(err=“”;@Success;

@Failure(“<FONT SIZE="-1" COLOR="C60031" FACE="VERDANA,ARIAL,HELVETICA">”

+“Sorry but your page can’t be saved!

There were validation errors:

    +@Implode(“

  • ”+@Explode(err;“~”;@False)+“
  • ”;“”)+“

+“<FONT SIZE="-1" FACE="VERDANA,ARIAL,HELVETICA">”

+“Click here to <A href="javascript: history.back()">” +

“<img src="/icons/prevview.gif" align=bottom border=0 alt="Your submission">” +

“return to your edits then make the changes and re-submit.
” +

“Click the link below if you want to abandon your submission


  • “<a href="”+db+“">”+@DbTitle+" home"))

Subject: RE: Re-display information on form after clicking the Back button or How to set a cookie

  1. There are 110 items in the form. For every item i placed in e.g @If(CK_1 = “”; @Failure(“Please do not leave any number unanswered. Click on your browser’s Back button to go back to the survey form”); @Success)

  2. In the Help of Designer 6.5.1, the syntax says:

@SetHTTPHeader( responseHeader ; value )

responseHeader

String. The name of a response-header field, for example, “Content-Encoding,” “Content-Length,” or “Set-Cookie.” See http:/www.w3.org/Protocols for specifications of response headers. The following response headers are read-only and cannot be set or overwritten using this function:

Connection

Content-Type

Date

Server

value

Text, number, or date. A value for the field. Dates are converted to RFC 1123 format. An empty string (“”) removes the header and its value from the HTTP response.

  1. From the Help,

@GetHTTPHeader( requestHeader )

Parameters

requestHeaderField

Text. The name of a request-header field, for example, “From,” “Host,” or “User-Agent.”

I would really appreciate all the help. Thank you.

Subject: RE: Re-display information on form after clicking the Back button or How to set a cookie

1a) I would HIGHLY recommend using javascript to validate instead of formula.

1b) If you really want to use formula language to validate your fields (yuck!), you could’ve used @If(@ThisValue = “”; …) in each field and not had to edit each field name in each formula.

2 & 3) Your responses suggest that you feel the syntax I gave you differs from the help. It doesn’t; it just uses an example involving cookies, which the help doesn’t.

Subject: RE: Re-display information on form after clicking the Back button or How to set a cookie

Don’t rely on javascript to do validation, always include a serverside validation too, so your ‘yuck’ is really out of place.

Subject: RE: Re-display information on form after clicking the Back button or How to set a cookie

There are a number of important limitations on the use of cookies by Web site developers. This is because cookies are intended to be used only for infrequent storage of small amounts of data on the user’s machine. The following limits generally apply:

300 Cookies total

20 Cookies per server (not per page or site)

4K of data Per cookie (both the name and value of the cookie count towards this limit)

I don’t think you want to be writing the values of 101 fields to a cookie. You should be doing data validation BEFORE the page is submitted so as to take the burden of validation off of the server and put it on the browser.

hth,

wmoze

Subject: interested in this topic, keep focusing on this

interested in this topic, keep focusing on this

Subject: Re-display information on form after clicking the Back button or How to set a cookie

For testing the site, use A3299 for the Employee number field