Removes an element from a structure.
Boolean value. The value depends on the indicatenotexisting parameter value.
StructDelete(structure, key [, indicatenotexisting ])
Structure functions; Modifying a ColdFusion XML object in Using XML and WDDX in ColdFusion MX Developer's Guide
ColdFusion MX: Changed behavior: this function can be used on XML objects.
| Parameter | Description |
|---|---|
|
structure |
Structure or a variable that contains one. Contains element to remove. |
|
key |
Element to remove. |
|
indicatenotexisting |
|
<h3>StructDelete Function</h3>
<!--- Delete the surrounding comments to make this page work
<p>This example uses the StructInsert and StructDelete functions.
<!--- Establish params for first time through --->
<cfparam name = "firstname" default = "Mary">
<cfparam name = "lastname" default = "Sante">
<cfparam name = "email" default = "msante@allaire.com">
<cfparam name = "phone" default = "777-777-7777">
<cfparam name = "department" default = "Documentation">
<cfif IsDefined("FORM.Delete")>
<cfoutput>
Field to be deleted: #form.field#
</cfoutput>
<p>
<CFScript>
employee = StructNew();
StructInsert(employee, "firstname", firstname);
StructInsert(employee, "lastname", lastname);
StructInsert(employee, "email", email);
StructInsert(employee, "phone", phone);
StructInsert(employee, "department", department);
</CFScript>
Before deletion, employee structure looks like this:
<cfdump var="#employee#">
<br>
<cfset rc = StructDelete(employee, "#form.field#", "True")>
<cfoutput>
Did I delete the field "#form.field#"? The code indicates: #rc#<br>
The structure now looks like this:<br>
<cfdump var="#employee#">
<br>
</cfoutput>
</cfif>
<br><br>
<form method="post" action = "#CGI.Script_Name#">
<p>Select the field to be deleted:
<select name = "field">
<option value = "firstname">first name
<option value = "lastname">last name
<option value = "email">email
<option value = "phone">phone
<option value = "department">department
</select>
<input type = "submit" name = "Delete" value = "Delete">
</form>
Delete this comment to make this page work --->