When the solution matters

Tips...

Registration Documentation Knowledgebase Seminars / Training Partner Programs 4D Partner Central

Surveys

Welcome to the 4D Dynamic Web Page Tutorial! The goal of this tutorial is to help you learn to create dynamic web pages and sites using 4th Dimension. Before you start this tutorial, it is a good idea to have first gone through the previous tutorial in this series - or at least be familiar with the material covered in it. As with the earlier tutorial, this one also assumes you have:

This step of the tutorial will create a simple on-line survey, present it to the user, save the user's answers in 4D's database, and return to the user a page showing how they answered the survey questions.

By now, you are well familiar with creating a new 4D application. Please do so now, and name your database "SurveyDB". You should also know how to enable your database for access via a web browser (by going to Database Properties in the Design environment, etc.). When you do enable the Web Server, make sure you mark the "Start without Context" checkbox. If you don't know how to do this, you should go back to some of the earlier tutorials in this series to see how.

The first thing we will do is set up a couple of tables to hold our survey data. By default, every 4D application has one database table (Table 1 is the default name). We will change the name of this table to "Surveys." To change the name of Table 1, first bring up the Database Structure window (in 4D's Design environment, choose Database Structure from the Tools menu). You should see Table 1; simply double-click on it. The Table Properties appear; here is where you can change the name to "Surveys".

Next, you will want to add three fields to it. To add a new field to a table, select it and then choose New Field... from the Structure menu. Here are the names and data types to add to the Surveys table.

 Name Data Type
 ID Long Integer
 Form_Name Alpha (20)
 Respondent_Name Alpha (20)

Next we will create a new table. Make sure you are still in 4D's Design environment. From the Structure menu, choose New Table... You are prompted to supply a table name; enter "Answers". The process for adding fields to the Answers table is the same as it was for Surveys. Just select the table (you should see a marquee around it) and choose New Field... from the Structure menu.

The fields to add to the Answers table are:

 Name

Data Type
ID Long Integer
ID_Survey Long Integer
Question Alpha (40)
Answer Alpha (80)

You will notice that the Data Type for the last two fields are followed by numbers enclosed in parenthesis. This refers to the length of the field - how many characters it can hold. You should set the "Question" field to be 40 characters long, and the "Answer" field to be 80 characters long. Look at the Field Properties for the Question field:

screenshot

The red circle highlights where you specify the Length for the field.

Once you have set up the Surveys and Answers tables, your Database Structure should look like this:

screenshot

 1 2 3 4 5 6  Next Step 


International | Company | Contact 4D | Site Map | Privacy Policy | © 4D, Inc. 1995-2008 | Change font size: [A] [A] [A] | Print this page | 4D RSS Feeds