< Previous | Next >

Lesson 1.5: Program the Submit button

When your input form is submitted, the page will automatically add the new record to the database. In this lesson, you will program the Post New Listing submit button to return to the all_records.jsp page so that you can immediately view the new record in the database.

To program the submit button:

  1. In the new_record.jsp file, right-click the Post New Listing button you created in the form on the Web page and select Properties.
  2. Click Add Rule. The Add Navigation Rule window opens.
  3. From the Page drop down, select all_records.jsp then click OK.
  4. Save the page. If you want to try adding a record to the database to verify that you will return to the all_records.jsp page, run new_record.jsp on your test server.
Prevent duplicate keys
Important:

Since the ID column is a primary key in the ADS table, you cannot add records with an ID value that already exists in the table. In Module 2, you will see how to use automatic key generation to automatically create a new unused key for each new record.

Until then, you must enter an unused ID number in this page to add a new record. The records that come with the database use ID numbers from 1 to 24, so you can enter any number above 24 as a primary key. Be sure not to duplicate keys if you enter more than one record.