Removes an element from a structure.
A structure, after removing the element.
StructDelete(structure, key [, indicatenotexisting ])
New in ColdFusion MX: this function can be used on XML objects.
<h3>StructDelete Function</h3> <p>This example uses the StructInsert and StructDelete functions. <!--- Establish parms 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> <cfoutput> employee is a structure: #IsStruct(employee)# </cfoutput> <cfset rc = StructDelete(employee, "#form.field#", "True")> <cfoutput> <p>Did I delete the field "#form.field#"? The code indicates: #rc# </p> </cfoutput> </cfif> <cfif NOT IsDefined("FORM.Delete")> <form action = "structdelete.cfm"> <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> </cfif>