You can use ActionScript in the following attribute of tags in CFML Flash format forms:
onSubmit
attribute of the cfform
tag, or the onChange
and onClick
attributes of the cfinput
tag. The attribute description on the tag reference pages in CFML Reference list the event attributes.
Your ActionScript code must be inline in the form attribute specification. You cannot create your own ActionScript function as a separate script and use it in the attribute value.
The following example shows a simple Fahrenheit to Celsius converter that does the conversion directly on the client, without requiring the user to submit a form to the ColdFusion server.
<cfform format="flash" width="200" height="150"> <cfinput type="text" name="fahrenheit" label="Fahrenheit" width="100" value="68"> <cfinput type="text" name="celsius" label="Celsius" width="100"> <cfinput type="button" name="convert" value="Convert" width="100" onClick="celsius.text = Math.round((farenheit.text-32)/1.8*10)/10"> </cfform>
Note: You do not use the text property (for example, fieldname.text
) to access hidden fields. To access a hidden field, use the format formname.fieldname = 'value'.