Microsoft KB Archive/214527

= FP97: Save Results Form Handler and Four-Digit Year Format =

Article ID: 214527

Article Last Modified on 8/27/2007

-

APPLIES TO


 * Microsoft FrontPage 97 Standard Edition

-



This article was previously published under Q214527



SUMMARY
The Save Results Form Handler allows you to specify whether to save Time or Date information along with each submitted form record. If you save this Date information, the date will be formatted in M/D/YY format. However, you can instruct FrontPage to output dates in the M/D/YYYY format. This article describes two methods you can use to format your dates in the M/D/YYYY format.



MORE INFORMATION
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this CODE "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Method 1: Using Active Server Pages (requires IIS or MSPWS)
If you are using Microsoft Internet Information Server (IIS) or Microsoft Personal Web Server (with the ASP patch installed), you can use Active Server Pages (ASP) to save the server's date as a part of the Save Results Form Handler. To do this, follow these steps:  In FrontPage Editor, open the page that contains the Save Results Form Handler. Place the cursor above the Form On the Insert menu, click HTML Markup. Enter the following ASP script in the HTML Markup dialog box, and then click OK:

<% FullDate = Month(date) & "/" & Day(date) & "/" & Year(date)

' FullDate is the combination of the exact Month, Day and Year.

' It will be used to assign the value of the hidden field. %>

 To create a hidden field, follow these steps:  Right-click the form, and then click Form Properties on the menu that appears. In the Hidden box, click Add.</li> In the Name box, type DateStamp .</li> In the Value box, type <%=FullDate%> .</li> Click OK twice.</li></ol> </li> Save the page as .asp where   is the name you want to assign to your page (Make sure the page is saved in a folder that allows scripts to be run).</li></ol>

For additional information about Active Server Pages, click the article numbers below to view the articles in the Microsoft Knowledge Base:

174008 FP98: What are Active Server Pages?

174015 FP98: How to Create Active Server Pages in FrontPage 98

Method 2: Using JavaScript (does not require IIS or MSPWS)
If you are not using Microsoft Internet Information Server or Microsoft Personal Web Server, you can use the following client-side JavaScript.

NOTE: This script returns the date of the client browser, rather than the date of the server.

<ol> In FrontPage Editor, open the page that contains the Save Results Form Handler.</li> Place the cursor above the form.</li> On the Insert menu, click Script.</li> Click to select the JavaScript check box.</li>  Paste the following code into the Script dialog box: // Give the function a name so the onSubmit event for the submit // button can call it. function FullYear { // Create a variable called ddate that will contain the current // date on the client system. var ddate= new Date; // Create a variable called year that will contain the current // year on the client system. Note that the JavaScript getYear method // will return values 0 through 99 for years 1900 through 1999, but // it will return 2000 or higher for years above 2000. var year=ddate.getYear // Analyze the current year, and if it is less than 100 (year 2000), // then add 1900 to it. if (year < 100) {year = (year + 1900)} // Specify that the return value of the function FullYear shall be a     // text string in the form of m/d/yyyy. The month portion is the // result of the getMonth method that returns 0 for January and 11 // for December. Add one to that value for the common representation //of a month. The date portion is the result of the getDate method, // and the year portion is the result of the calculation within the // if condition in the line above. return ((ddate.getMonth + 1)+ "/" + ddate.getDate+ "/" + year); }                   </li> On the View menu, click HTML.</li> Add the onClick event to the Submit button code. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> Find the HTML code that resembles the following:

<input type="submit" value="Submit" name="B1">

</li> Add the following code after name="B1" but before the > sign:

onClick="DateStamp.value=FullYear"

</li> The HTML code should look similar to the following:

<input type="submit" value="Submit" name="B1" onClick="DateStamp.value=FullYear">

</li></ol> </li> Add a hidden field named DateStamp to the form by typing the following HTML code right after the tag in the previous step:

<input type="hidden" name="DateStamp">

</li></ol>

<div class="references_section">