Dreamweaver CS4 Resources
|
Create links to a delete page
After creating the search and results pages,
you must create links on the results page to open the delete page.
You then modify the links to pass the IDs of the records the user
wants to delete. The delete page uses this ID to find and display the
record.
To create the links manually- On the results page, create a column
in the table used to display records by clicking inside the last
table column and selecting Modify > Table >
Insert Rows or Columns.
- Select the Columns option and the After Current Column
option, and click OK.
A column is added to the table.
- In the newly created table column, enter the string Delete in
the row containing the dynamic content placeholders. Make sure you
enter the string inside the tabbed repeating region.
You can also insert an image with a word or symbol for
delete.
If Live Data view is enabled, enter the string in
the first row of records and click the Refresh icon.
- Select the Delete string to apply a
link to it.
If Live Data view is enabled, select the string in the
first row of records.
- In the Property inspector, enter the delete page in the
Link box. You can enter any filename.
After clicking outside the Link box, the Delete string
appears linked in the table. If you enable Live Data view (View >
Live Data), you can see that the link is applied to the same text
in every table row. If Live Data view is already enabled, click
the Refresh icon to apply the links to each row.
- Select the Delete link on the results page.
If Live Data view is enabled, select the link in the first
row.
- (ColdFusion) In the Link box in the Property inspector,
add the following string at the end of the URL:
?recordID=#recordsetName.fieldName#
The
question mark tells the server that what follows is one or more
URL parameters. The word recordID is the name of the URL parameter
(you can make up any name you like). Note the name of the URL parameter
because you'll use it in the delete page later.
The expression
after the equal sign is the value of the parameter. In this case,
the value is generated by a ColdFusion expression that returns a
record ID from the recordset. A different ID is generated for each
row in the dynamic table. In the ColdFusion expression, replace recordsetName with
the name of your recordset, and replace fieldName with
the name of the field in your recordset that uniquely identifies
each record. In most cases, the field will consist of a record ID
number. In the following example, the field consists of unique location codes:
confirmDelete.cfm?recordID=#rsLocations.CODE#
When
the page runs, the values of the recordset's CODE field are inserted
in the corresponding rows in the dynamic table. For example, if
the Canberra, Australia, rental location has the code CBR, the following
URL is used in the Canberra row in the dynamic table:
confirmDelete.cfm?recordID=CBR
- (PHP) In the Link field in the Property inspector, add
the following string at the end of the URL:
?recordID=<?php echo $row_recordsetName['fieldName']; ?>
The
question mark tells the server that what follows is one or more
URL parameters. The word recordID is the name of the URL parameter
(you can make up any name you like). Note the name of the URL parameter
because you'll use it in the delete page later.
The expression
after the equal sign is the value of the parameter. In this case,
the value is generated by a PHP expression that returns a record
ID from the recordset. A different ID is generated for each row
in the dynamic table. In the PHP expression, replace recordsetName with
the name of your recordset, and replace fieldName with
the name of the field in your recordset that uniquely identifies
each record. In most cases, the field will consist of a record ID
number. In the following example, the field consists of unique location
codes:
confirmDelete.php?recordID=<?php echo $row_rsLocations['CODE']; ?>
When
the page runs, the values of the recordset's CODE field are inserted
in the corresponding rows in the dynamic table. For example, if
the Canberra, Australia, rental location has the code CBR, the following
URL is used in the Canberra row in the dynamic table:
confirmDelete.php?recordID=CBR
- (ASP) In the Link field in the Property inspector, add
the following string at the end of the URL:
?recordID=<%=(recordsetName.Fields.Item("fieldName").Value)%>
The
question mark tells the server that what follows is one or more
URL parameters. The word recordID is the name of the URL parameter
(you can make up any name you like). Note the name of the URL parameter
because you'll use it in the delete page later.
The expression
after the equal sign is the value of the parameter. In this case,
the value is generated by an ASP expression that returns a record
ID from the recordset. A different ID is generated for each row
in the dynamic table. In the ASP expression, replace recordsetName with
the name of your recordset, and replace fieldName with
the name of the field in your recordset that uniquely identifies
each record. In most cases, the field will consist of a record ID
number. In the following example, the field consists of unique location
codes:
confirmDelete.asp?recordID=<%=(rsLocations.Fields.Item("CODE").Value)%>
When
the page runs, the values of the recordset's CODE field are inserted
in the corresponding rows in the dynamic table. For example, if
the Canberra, Australia, rental location has the code CBR, the following
URL is used in the Canberra row in the dynamic table:
confirmDelete.asp?recordID=CBR
- Save the page.
To create the links visually (ASP only)- On the results page, create a column
in the table used to display records by clicking inside the last
table column and selecting Modify > Table >
Insert Rows or Columns.
- Select the Columns option and the After Current Column
option, and click OK.
A column is added to the table.
- In the newly created table column, enter the string Delete in
the row containing the dynamic content placeholders. Make sure you
enter the string inside the tabbed repeating region.
You can also insert an image with a word or symbol for
delete.
If Live Data view is enabled, enter the string in
the first row of records and click the Refresh icon.
- Select the Delete string to apply a
link to it.
If Live Data view is enabled, select the string in the
first row of records.
- In the Server Behaviors panel (Window > Server
Behaviors), click the Plus (+) button, and select Go to Detail Page
from the pop‑up menu.
- In the Detail Page box, click Browse and locate the delete
page.
- In the Pass URL Parameter box, specify the name of your
parameter, such as recordID.
You can make up any name you like, but take note of the
name because you'll use it in the delete page later.
- Specify the value you want to pass to the delete page
by selecting a recordset and a column from the Recordset and Column
pop‑up menus. Typically the value is unique to the record, such
as the record’s unique key ID.
- Select the URL Parameters option.
- Click OK.
A special link surrounds the selected text. When the user
clicks the link, the Go To Detail Page server behavior passes a
URL parameter containing the record ID to the specified delete page.
For example, if the URL parameter is called recordID and the delete
page is called confirmdelete.asp, the URL looks something like the following
when the user clicks on the link:
http://www.mysite.com/confirmdelete.asp?recordID=43
The
first part of the URL, http://www.mysite.com/confirmdelete.asp,
opens the delete page. The second part, ?recordID=43, is the URL
parameter. It tells the delete page what record to find and display.
The term recordID is the name of the URL parameter and 43 is its
value. In this example, the URL parameter contains the record’s
ID number, 43.
|