How to update a structure key with a value in ColdFusion

StructUpdate() - update a structure key with a value

StructUpdate.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>StructUpdate function example: how to update a structure key with a value</title>
</head>

<body>
<h2 style="color:HotPink">StructUpdate Function Example</h2>

<cfset Color=StructNew()>
<cfset Color.ID=1>
<cfset Color.Name="LightGray">
<cfset Color.Value="##D3D3D3">
<cfdump var="#Color#" label="Color">

<br />
<cfset Temp=StructUpdate(Color,"Name","LightGreen")>
<cfset Temp=StructUpdate(Color,"Value","##90EE90")>
<cfdump var="#Color#" label="Color[after update]">

</body>
</html>






More ColdFusion examples