<cfform name = "name" action = "form_action" preserveData = "Yes" or "No" enableCAB = "Yes" or "No" onSubmit = "javascript" target = "window_name" encType = "type" passThrough = "HTML_attributes" codeBase = "URL" archive = "URL" > ... </cfform>
B
uilds a form with CFML custom control tags that provide more functionality than standard HTML form input elements.
Note The |
cfapplet,
cfgrid,
cfinput,
cfselect,
cfslider,
cftextinput,
cftree
ColdFusion provides the following custom control tags:
You can add standard and dynamic HTML form
tag attributes and their values to the cfform
tag by using the passThrough
attribute. The attributes and values are passed through ColdFusion to the browser in creating a form.
If you specify a value in quotation marks, you must escape the quotation marks by doubling them; for example,
passThrough = "readonly = " "YES " " "
The cfform
tag lets you incorporate standard HTML in two ways:
form
tag attributes and values to the cfform
tag. The attributes and values are passed through ColdFusion to the browser in creating a form. For example, you can use form
tag attributes like target
to enhance your cfform
features.
form
tag between <cfform>
and </cfform>
tags.
For example, you use a standard HTML input
tag to create a submit button in a cfform
:
<cfform>
<input type = "Submit" value = " update... "> </cfform>
<!--- This example shows the use of cfinput controls in a cfform ---> <html> <head> <title> cfform Example </title> </head> <body> <H3>cfform Example</H3> <cfif IsDefined("form.oncethrough") is "Yes"> <cfif IsDefined("form.testVal1") is True> <H3>Results of Radio Button Test</H3> <cfif form.testVal1 is "Yes">Your radio button answer was yes</cfif> <cfif form.testVal1 is "No">Your radio button answer was no</cfif> </cfif> <cfif IsDefined("form.chkTest2") is True> <H3>Results of Checkbox Test</H3> Your checkbox answer was yes <cfelse> <H3>Results of Checkbox Test</H3> Your checkbox answer was no </cfif> <cfif IsDefined("form.textSample") is True AND form.textSample is not ""> <H3>Results of Credit Card Input</H3> Your credit card number, <cfoutput>#form.textSample#</cfoutput>, was valid under the MOD 10 algorithm. </cfif> <cfif IsDefined("form.sampleSlider") is "True"> <H3>You gave this page a rating of <cfoutput>#form.sampleSlider# </cfoutput></H3> </cfif> <hr noshade> </cfif> <!--- begin by calling the cfform tag ---> <cfform action = "cfform.cfm" method = "POST" enableCAB = "Yes"> <table> <TR> <TD> <H4>This example displays the radio button input type for cfinput.</H4> Yes <cfinput type = "Radio" name = "TestVal1" value = "Yes" checked> No <cfinput type = "Radio" name = "TestVal1" value = "No"> </TD> </TR> <TR> <TD> <H4>This example displays the checkbox input type for cfinput.</H4> <cfinput type = "Checkbox" name = "ChkTest2" value = "Yes"> </TD> </TR> <TR> <TD> <H4>This example shows a client-side validation for cfinput text boxes.</H4> <BR>(<I>This item is optional</I>)<BR> Please enter a credit card number: <cfinput type = "Text" name = "TextSample" message = "Please enter a Credit Card Number" validate = "creditcard" required = "No"> </TD> </TR> <TR> <TD> <H4>This example shows the use of the CFSLIDER tag.</H4> <P>Rate your approval of this example from 1 to 10 by sliding the control. <P>1 <CFSLIDER name = "sampleSlider" LABEL = "Sample Slider" range = "1,10" message = "Please enter a value from 1 to 10" scale = "1" bold = "No" italic = "No" REFRESHLABEL = "No"> 10 </TD> </TR> </table> <P><input type = "SUBMIT" name = "SUBMIT" value = "show me the result"> <input type = "hidden" name = "oncethrough" value = "Yes"> </cfform> </body> </html>