#### Making basic web controls work in a form

In order to make web controls accept user inputs and submit requests to JReport Server, you must add the web controls to a form and then define some properties of the form.

##### Creating a form

To create a form in a report, you can do either of the following:

- Click Insert > Web Controls > Form.
- Drag Form from the Toolbox panel to the report.

The following are commands on the shortcut menu of a form:

- Unmark Form: Deselects this form.
- Delete Form: Deletes this form.
- Remove All Controls: Removes all the objects added to the form.
- Properties: Shows the properties of the form.

##### Adding an object to a form

To add an object to a form, right-click the object, and on the shortcut menu, select the required item from the Add to Form submenu. The object can be added to a new form or an existing one. In JReport Designer, the icon represents a form. If you click the icon, you will find that the form and all the objects added to it are enclosed by a red dashed outline.

After an object has been added to a form, if you want to remove it from the form, you can right-click the object and select Remove from Form from the shortcut menu.

##### Making web controls work in a form

After adding web controls to a form, you need to make the web controls cooperate, that is, you must set some properties of the form so as to organize the web controls and define their working mode. To do this, select the form, open the Report Inspector, and then edit the properties of the form.

Here is an example illustrating the use of form. In this example, a text field and a button in a report enable the report user to search for a particular string with Google.

1. Create a report which contains a blank flow report tab.
2. In the report tab, insert two web controls: a Text Field and a Button.
3. Right-click the text field, select Display Type from the shortcut menu, then in the Display Type dialog, set the following options (leave other options to the default values):

   Name: q
   Value: "" (null)
   Max Length: 30

4. Right-click the button, click Display Type on the shortcut menu and set the following options in the Display Type dialog:

   Value: Google
   Action: Submit Form

5. Select the two web controls, then right-click and select Add to Form > Add to New Form from the shortcut menu.
6. Set the properties of the form in the Report Inspector as follows:

   Form Action: http://www.google.com/search
   Form Method: get
   Form Target: blank

7. Save the report and preview it in Page Report Studio.

   Now you can input a string up to 30 characters in the text field, and then click the button Google to search for that string. The search result will be displayed in a new browser window.

Note: For a table, if you add a field to a new form, the form will be created in the first cell of the table row which contains the field, and fields in the previous table rows cannot be added to this newly-created form. If you add columns before the first cell, then fields in these columns of the same table row also cannot be added to the form.