When building a website where your users need to insert information into a database, you may want to allow them to submit multiple entries at once. This tutorial will demonstrate how to take a simple form and use Data Bridge or DataAssist to convert it into a multiple record insert form.
Inserting multiple records requires two main steps. First you will set up the number of records you’d like the user to be able to insert.
1. Open the sample file in your site. Each of your form elements should have unique names. This example has 4 text fields: First Name (FN), Last Name (LN), Username (UN), and Password (PW).
2. Placing your cursor in the form element row, choose the <tr> tag from the Tag Selector.
3. From the Server Behaviors panel, click + and choose WebAssist > DataAssist > Repeat Selection.
4. In DataAssist Repeat Selection, leave the Recordset list set to None. Because you’re specifying a set value of entries to repeat, there’s no need to loop through a recordset.
5. Set the Repetitions to the number of entries you’d like. For example, 5. Click OK.
6. Take note that Dreamweaver has surrounded the table row with a Repeat Selection tab and border.
7. Save your page. (Ctrl or Cmd + S)
Now that the multiple rows have been defined, let’s apply the Multiple Record Inserts server behavior.
1. From the Server Behaviors panel, click + and choose WebAssist > DataAssist > Insert > Multiple Record Inserts.
2. When the Insert Multiple Records wizard opens, select the event to execute the server behavior from the Trigger list by choosing Button: submit pressed.
3. Next, choose the repeat selection that holds the form elements you want reiterated. In this situation, there is only one repeat selection available. So you can leave the default setting, Repeat Selection (5).
4. From the Skip if empty list, choose the primary field you want to make sure is entered. Let’s choose Last Name (LN). Alternatively, you could choose Always insert to force every data row to create a record, regardless of whether the data entered is complete or not.
5. In the Database section, choose the desired database connection from the Connection list. In this example, the database is tut_00_11. Then choose the table you want to insert the records into from the Table list.
6. If you’d like to display a particular page after the insert operation is complete, enter its path and filename in the Go to (optional) field or select the page by clicking the folder icon. To see that your records have been added, select the results page.
7. On the second step of the Insert Multiple Records wizard, you’ll bind the database columns in the chosen table to the form fields on the current page. Click the Bindings tab.
8. Select each database column into which you want to enter data from the Column list and then, if necessary, modify the Data Type.
9. Finally, click the lightning bolt icon to open the Dynamic Data dialog and then expand the form entry to locate the proper field. Click OK once to return to the Insert Multiple Records wizard and repeat this step for the next required database column.
10. Since the form contains entries for the visitor’s first name, last name, username and password, select the corresponding database columns and bind them. Click Finish.
11. Save your page (Ctrl or Cmd + S) and preview (F12) to see your 5 entries rows.
Now your application is ready to accept multiple records in a single page.
DataAssist also allows you to create a multiple record update form and a multiple record delete form. View the tutorials at Create a multiple record update form and Create a multiple record delete form.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.