The bind attribute lets you set the value of the fields using the contents of other form fields. You can use the bind attribute with the cftextarea tag and any cfinput type that takes a value, including hidden. This data binding occurs dynamically as the user enters data within Flash on the client system. Flash does not send any information to ColdFusion until the user submits the form. To use the bind attribute to specify the field value, use the following formats:
Data source |
bind attribute format |
---|---|
cfinput type = "text" or cftextarea text |
bind="{sourceName.text}" |
cfinput selected radio button |
bind="{sourceName.selectedData}" |
cftree selected item |
bind="{sourceName.selectedNode.getProperty('data').value} |
cfgrid selected item |
bind="{sourceName.selectedItem.COLUMNAME}" |
cfselect selected item |
bind="{sourceName.selectedItem.data}" |
The following rules and techniques apply to the binding formats:
The following example shows how to use the values from the firstName and lastName fields to construct an e-mail address. The user can change or replace this value with a typed entry.
<cfformgroup type="horizontal" label="Your Name"> <cfinput type="text" required="Yes" name="firstName" label="First" value="" width="100"/> <cfinput type="text" required="Yes" name="lastName" label="Last" value="" width="100"/> </cfformgroup> <cfinput type="text" name="email" label="email" bind="{firstName.text}.{lastName.text}@mm.com">