Better form coding
Forms are a big part of what developers do on web pages. We will first show how to use COOP forms and then we will show how to use the special attributes and layout features of the forms tags in COOP.
Here is a simple form that has a select list and a submit button. Some tags always require an ID, but as you can see in our sample there are tags like the submit tag that you are allowed to code without the ID attribute. Create a file called form.cfm
:
<cfimport prefix="coop" taglib="/share/tags/coop"/> <coop:coop> <coop:form id="myForm"> <coop:selectList id="mySelect" label="Select List"data="one,two,three,four" selected="three" /> <coop:submit value="Send Selection"/> </coop:form> </coop:coop>
The form tag, like most COOP element tags, requires an ID attribute field. When we run this code, we see it operates completely as expected. Again, we will wait on the logic side of form handling for the next chapter. Right now we...