• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Project 12. Producing a Sophisticated In... > Editing and Deleting Records

Editing and Deleting Records

What happens when you misspell your boss’ name or need to get rid of a record that you added last week? In this section, you’ll be creating an Edit page where you can change and delete records.

Open edit.cfm from the Files panel.

Open index.cfm and open the Bindings panel. Select the rs_news recordset, right-click/Ctrl-click, choose Copy, and close index.cfm. In edit.cfm, right-click/Ctrl-click in the Bindings panel and choose Paste.

To edit a record, you first need to copy over the recordset full of data to retrieve the information on the edit page.

Double-click the rs_news recordset in the Bindings panel to open the Recordset dialog. For the Filter drop-down, choose news_id. Leave the next two fields at their defaults, = and URL Parameter. Enter recordID in the last field, which is the URL parameter passed from index.cfm.

Insert an Update Record Form by using Insert > Application Objects > Update Record > Record Update Form Wizard.

Complete the Record Update Form dialog:

Data Source: cf_dwmagic

User Name: blank

Password: blank

Table to Update: News

Select Record From: rs_news

Unique Key Column: news_id, leave Numeric checked

After Updating, Go To: index.cfm

Pass Original Querystring: Unchecked

Form Fields:

news_id: Remove the record ID. The user should never be allowed to change IDs.

news_date: Change the label to Date (MM/DD/YY): and ensure the date is submitted as Text

news_title: Change the label to Title:

news_text: Change the label to News:

Click the news_date text field, open the Bindings panel, open the List menu in the format column for the news_date, and choose Date/Time > 01/17/00. This sets the date to an easily readable format.


You can add the Validate Form behavior to ensure the date is in the desired format before submitting the form.

Click the text field for News and press Delete to remove it. Leave the cursor in the table cell and choose Insert > ColdFusion Objects > Advanced > XHTML Editor and complete the CF XHTML Editor dialog and click OK.

Field Name: news_text

Field Value: Click the lightning bolt icon, choose news_text from the rs_news recordset, click OK

Redirect: ie_only.cfm

CSSfile: style.css

Width: blank

Height: 300

Similar to what you did for the insert, this removes the default field for news_text and replaces it with the editor.

Save edit.cfm to test editing records.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint