johnbarrett
11/23/2022, 7:38 AM<cfif #form.conversionType# is "CtoF"> <cfinvoke component="convertTemp" method="ctof" returnvariable="newtemp" temp=#form.temperature#>
<cfoutput>#form.temperature# degrees Celsius is #newtemp# degrees Farenheit.</cfoutput>
<cfelseif #form.conversionType# is "FtoC">
<cfinvoke component="convertTemp" method="ftoc" returnvariable="newtemp" temp=#form.temperature#>
<cfoutput>#form.temperature# degrees Fahrenheit is #newtemp# degrees Celsius.</cfoutput>
</cfif>
Adam Cameron
chris-schmitz
11/23/2022, 10:31 AM// if conversionType exists, the form was sent. Make sure temperature is a numeric value
if( structKeyExists( form, 'conversionType') && isNumeric( form.temperature ) ) {
conversionResult = new convertTemp.convert( direction=form.conversionType, temperature=form.temperature )
writeOutput( '#form.temperature# degrees #conversionResult.from# is #conversionResult.newTemp# #<http://conversionResult.to#|conversionResult.to#>.' );
}
In the example above, the CFC method would return a struct with the output values. In case you don't need the values later in the request, you could just as well have it return a complete output string.Patrick
11/23/2022, 2:18 PMJohn Wilson
11/23/2022, 4:34 PMJim Priest
11/23/2022, 10:53 PMJim Priest
11/23/2022, 10:54 PMAdam Cameron
Michael Schmidt
11/28/2022, 4:53 PM