|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
CFC and HTML
I'm building an application. I have a table full of teams. I will have a select box containing said teams on different pages. Like so:
<!--- the query ---> <cfquery name="getTeams"> SELECT * FROM team_list ORDER BY team_title </cfquery> <!--- the select statement ---> <select name="sport_category"> <option value="0">No Specific Team</option> <cfoutput query="getTeams"><option value="#ID#">#team_title#</option></cfoutput> </select> I'm planning to use a CFC to run the getTeams query (the query that pulls the team information). However, what would be the best way to construct the select box code? My options, the way I see it are: 1. use an include file that contains the select box html and calls the CFC. 2. Set up the select box code as a string within the CFC and return it as a string. 3. create a custom tag. 4. Have the HTML code on every page (which I won't seriously consider). What would be the best (and fastest way)? Is there a way to pop out HTML using a CFC that I haven't found in my research? Any help is appreciated! |
|
#2
|
|||
|
|||
|
CFC's are primarily meant to handle business logic, not presentation. If you want to use a CFC to provide the query, simply write a CFC method that returns a query and call it from your form.
<cfset getTeams = myCFC.getTeams() /> <select name="sport_category"> <option value="0">No Specific Team</option> <cfoutput query="getTeams"><option value="#ID#">#team_title#</option></cfoutput> </select> Or if you are using MVC, have your controller call the method and then your display page won't even have to know that a CFC is being used.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Quote:
That's what I thought. I was just hoping I missed something in my researcy I'll probably use an include so at least the select box code is in one location. Thanks for your help. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > CFC and HTML |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|