8.2. Looking at Choice Sections and the Choice Group Control

Choice sections and groups are very useful when you display and store a set of data in a form based on a choice the user makes. There is no need to have fields on the form that don't need to be filled in if the data is not going to be used. In some form packages:

  • Developers have to programmatically disable or make fields invisible.

  • Users have to tab over the fields that aren't necessary.

The Choice Group control solves the problem by displaying data in choice sections based on the choices made.

A good example, and one you will deal with in this chapter's Try It Out is what information you want filled out when a user chooses the type of payment he or she wants to make for an order, such as Cash, Check, or Charge. You can see final form with the payment choice of Charge selected in Figure 8-1.

Figure 8.1. Figure 8-1

The credit card number is located under the menu in Figure 8-1. When the payment choice is Check, the form looks as shown in Figure 8-2.

Figure 8.2. Figure 8-2

When the choice is Cash, then no fields are displayed in the section.

After dragging a Choice Group control onto the form, two Choice Section controls are added by default. You will then add controls to each of the sections, based on the data you want the user to edit in each. To have the menu display the various names of the choices, the field name is filled in using the Choice Section property sheet. To add an additional choice to the Group Choice control, Choice Section is selected from the Advanced section of the Insert Controls task pane. This will all become clearer as you work on the following Try It Out.

8.2.1.

8.2.1.1. Try It Out: Adding a Choice Group Control

For the purpose of this Try it Out, you will be creating a new form. When completed it will look as it does in Figure 8-3.

Figure 8.3. Figure 8-3

  1. Open Microsoft InfoPath 2003. The Fill Out a Form dialog box is displayed.

  2. Choose Design a Form.

  3. Click on New Blank Form from within the Design a Form task pane. A blank form will be displayed.

  4. Add a Table with Title from the Layout task pane.

  5. Add the controls and text as displayed in Figure 8-4. What the names of the controls are isn't important for this Try It Out.

    Figure 8.4. Figure 8-4
  6. Drag a Choice Group control from the Advanced section of the Controls task pane. You will see the control displayed on the form as shown in Figure 8-5.

  7. Add the desired controls to the first two sections—in this case, nothing in the first section and a 3-column table with a label and text box for the Check Number as shown in Figure 8-3.

    Figure 8.5. Figure 8-5
  8. Drag and drop a Choice Section control from the Advanced section of the Controls task pane into the bottom of Choice Group control.

  9. Add a three-column table with the necessary controls, as shown in Figure 8-6.

    Figure 8.6. Figure 8-6
  10. Next, to have the choices displayed, click Preview Form, and click the area below the prompt: Please choose Cash, Check, or Charge.

  11. Make your selections, and the form will be displayed as shown in Figures 8-1 and 8-2.

One issue with binding the choice group to a database is that you need to have the data structured as it is on the form. Therefore, it is simplest to use the control with a new form, creating the XML schema with the form.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.128.226