File indexing completed on 2025-02-02 03:54:44
0001 <!DOCTYPE html> 0002 <html><head> 0003 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 0004 <title>highlight.cfml</title> 0005 <meta name="generator" content="KF5::SyntaxHighlighting - Definition (ColdFusion) - Theme (Breeze Light)"/> 0006 </head><body style="background-color:#ffffff;color:#1f1c1b"><pre> 0007 <span style="color:#898887"><!--- ColdFusion Sample File ---></span> 0008 <span style="color:#898887"><!--- Source: https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/using-arrays-and-structures/structure-examples.html ---></span> 0009 0010 <span style="font-weight:bold"><head></span> 0011 <span style="font-weight:bold"><title></span>Add New Employees<span style="font-weight:bold"></title></span> 0012 <span style="font-weight:bold"></head></span> 0013 0014 <span style="font-weight:bold"><body></span> 0015 <span style="font-weight:bold"><h1></span>Add New Employees<span style="font-weight:bold"></h1></span> 0016 <span style="color:#898887"><!--- Action page code for the form at the bottom of this page. ---></span> 0017 0018 <span style="color:#898887"><!--- Establish parameters for first time through ---></span> 0019 <span style="color:#644a9b;font-weight:bold"><cfparam</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"Form.firstname"</span><span style="color:#006e28"> default</span>=<span style="color:#bf0303">""</span><span style="color:#644a9b;font-weight:bold">></span> 0020 <span style="color:#644a9b;font-weight:bold"><cfparam</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"Form.lastname"</span><span style="color:#006e28"> default</span>=<span style="color:#bf0303">""</span><span style="color:#644a9b;font-weight:bold">></span> 0021 <span style="color:#644a9b;font-weight:bold"><cfparam</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"Form.email"</span><span style="color:#006e28"> default</span>=<span style="color:#bf0303">""</span><span style="color:#644a9b;font-weight:bold">></span> 0022 <span style="color:#644a9b;font-weight:bold"><cfparam</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"Form.phone"</span><span style="color:#006e28"> default</span>=<span style="color:#bf0303">""</span><span style="color:#644a9b;font-weight:bold">></span> 0023 <span style="color:#644a9b;font-weight:bold"><cfparam</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"Form.department"</span><span style="color:#006e28"> default</span>=<span style="color:#bf0303">""</span><span style="color:#644a9b;font-weight:bold">></span> 0024 0025 <span style="color:#898887"><!--- If at least the firstname form field is passed, create</span> 0026 <span style="color:#898887">a structure named employee and add values. ---></span> 0027 <span style="color:#644a9b;font-weight:bold"><cfif #Form.firstname# eq </span><span style="color:#bf0303">""</span><span style="color:#644a9b;font-weight:bold">></span> 0028 <span style="font-weight:bold"><p></span>Please fill out the form.<span style="font-weight:bold"></p></span> 0029 <span style="color:#644a9b;font-weight:bold"><cfelse></span> 0030 <span style="color:#644a9b;font-weight:bold"><cfoutput></span> 0031 <span style="color:#bf0303;font-weight:bold"><cfscript></span> 0032 employee<span style="font-weight:bold">=</span><span style="color:#644a9b;font-weight:bold">StructNew</span><span style="font-weight:bold">()</span>; 0033 employee.firstname <span style="font-weight:bold">=</span> Form.firstname; 0034 employee.lastname <span style="font-weight:bold">=</span> Form.lastname; 0035 employee.email <span style="font-weight:bold">=</span> Form.email; 0036 employee.phone <span style="font-weight:bold">=</span> Form.phone; 0037 employee.department <span style="font-weight:bold">=</span> Form.department; 0038 <span style="color:#bf0303;font-weight:bold"></cfscript></span> 0039 0040 <span style="color:#898887"><!--- Display results of creating the structure. ---></span> 0041 First name is #StructFind(employee, "firstname")#<span style="font-weight:bold"><br></span> 0042 Last name is #StructFind(employee, "lastname")#<span style="font-weight:bold"><br></span> 0043 EMail is #StructFind(employee, "email")#<span style="font-weight:bold"><br></span> 0044 Phone is #StructFind(employee, "phone")#<span style="font-weight:bold"><br></span> 0045 Department is #StructFind(employee, "department")#<span style="font-weight:bold"><br></span> 0046 <span style="color:#644a9b;font-weight:bold"></cfoutput></span> 0047 0048 <span style="color:#898887"><!--- Call the custom tag that adds employees. ---></span> 0049 <span style="color:#0057ae;font-weight:bold"><cf_addemployee</span><span style="color:#006e28"> empinfo</span>=<span style="color:#bf0303">"#employee#"</span><span style="color:#0057ae;font-weight:bold">></span> 0050 <span style="color:#644a9b;font-weight:bold"></cfif></span> 0051 0052 <span style="color:#898887"><!--- The form for adding the new employee information ---></span> 0053 <span style="font-weight:bold"><hr></span> 0054 <span style="font-weight:bold"><form</span><span style="color:#006e28"> action</span>=<span style="color:#bf0303">"newemployee.cfm"</span><span style="color:#006e28"> method</span>=<span style="color:#bf0303">"Post"</span><span style="font-weight:bold">></span> 0055 First Name:<span style="color:#b08000">&nbsp;</span> 0056 <span style="font-weight:bold"><input</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"firstname"</span><span style="color:#006e28"> type</span>=<span style="color:#bf0303">"text"</span><span style="color:#006e28"> hspace</span>=<span style="color:#bf0303">"30"</span><span style="color:#006e28"> maxlength</span>=<span style="color:#bf0303">"30"</span><span style="font-weight:bold">><br></span> 0057 Last Name:<span style="color:#b08000">&nbsp;</span> 0058 <span style="font-weight:bold"><input</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"lastname"</span><span style="color:#006e28"> type</span>=<span style="color:#bf0303">"text"</span><span style="color:#006e28"> hspace</span>=<span style="color:#bf0303">"30"</span><span style="color:#006e28"> maxlength</span>=<span style="color:#bf0303">"30"</span><span style="font-weight:bold">><br></span> 0059 EMail:<span style="color:#b08000">&nbsp;</span> 0060 <span style="font-weight:bold"><input</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"email"</span><span style="color:#006e28"> type</span>=<span style="color:#bf0303">"text"</span><span style="color:#006e28"> hspace</span>=<span style="color:#bf0303">"30"</span><span style="color:#006e28"> maxlength</span>=<span style="color:#bf0303">"30"</span><span style="font-weight:bold">><br></span> 0061 Phone:<span style="color:#b08000">&nbsp;</span> 0062 <span style="font-weight:bold"><input</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"phone"</span><span style="color:#006e28"> type</span>=<span style="color:#bf0303">"text"</span><span style="color:#006e28"> hspace</span>=<span style="color:#bf0303">"20"</span><span style="color:#006e28"> maxlength</span>=<span style="color:#bf0303">"20"</span><span style="font-weight:bold">><br></span> 0063 Department:<span style="color:#b08000">&nbsp;</span> 0064 <span style="font-weight:bold"><input</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"department"</span><span style="color:#006e28"> type</span>=<span style="color:#bf0303">"text"</span><span style="color:#006e28"> hspace</span>=<span style="color:#bf0303">"30"</span><span style="color:#006e28"> maxlength</span>=<span style="color:#bf0303">"30"</span><span style="font-weight:bold">><br></span> 0065 0066 <span style="font-weight:bold"><input</span><span style="color:#006e28"> type</span>=<span style="color:#bf0303">"Submit"</span><span style="color:#006e28"> value</span>=<span style="color:#bf0303">"OK"</span><span style="font-weight:bold">></span> 0067 <span style="font-weight:bold"></form></span> 0068 <span style="font-weight:bold"><br></span> 0069 <span style="font-weight:bold"></body></span> 0070 <span style="font-weight:bold"></html></span> 0071 0072 <span style="color:#644a9b;font-weight:bold"><cfoutput></span> 0073 Error. No employee data was passed.<span style="font-weight:bold"><br></span> 0074 <span style="color:#644a9b;font-weight:bold"></cfoutput></span> 0075 <span style="color:#644a9b;font-weight:bold"><cfexit</span><span style="color:#006e28"> method</span>=<span style="color:#bf0303">"ExitTag"</span><span style="color:#644a9b;font-weight:bold">></span> 0076 <span style="color:#644a9b;font-weight:bold"><cfelse></span> 0077 <span style="color:#898887"><!--- Add the employee ---></span> 0078 <span style="color:#644a9b;font-weight:bold"><cfquery</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"AddEmployee"</span><span style="color:#006e28"> datasource</span>=<span style="color:#bf0303">"cfdocexamples"</span><span style="color:#644a9b;font-weight:bold">></span> 0079 INSERT INTO Employees 0080 (FirstName, LastName, Email, Phone, Department) 0081 VALUES ( 0082 '#attributes.empinfo.firstname#' , 0083 '#attributes.empinfo.lastname#' , 0084 '#attributes.empinfo.email#' , 0085 '#attributes.empinfo.phone#' , 0086 '#attributes.empinfo.department#' ) 0087 <span style="color:#644a9b;font-weight:bold"></cfquery></span> 0088 <span style="color:#644a9b;font-weight:bold"></cfif></span> 0089 <span style="color:#644a9b;font-weight:bold"><cfoutput></span> 0090 <span style="font-weight:bold"><hr></span>Employee Add Complete 0091 <span style="color:#644a9b;font-weight:bold"></cfoutput></span> 0092 0093 <span style="color:#898887"><!--- temperature.cfc ---></span> 0094 <span style="color:#644a9b;font-weight:bold"><cfcomponent></span> 0095 <span style="color:#644a9b;font-weight:bold"><cffunction</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"FtoC"</span><span style="color:#006e28"> access</span>=<span style="color:#bf0303">"public"</span><span style="color:#006e28"> returntype</span>=<span style="color:#bf0303">"numeric"</span><span style="color:#644a9b;font-weight:bold">></span> 0096 <span style="color:#644a9b;font-weight:bold"><cfargument</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"fahrenheit"</span><span style="color:#006e28"> required</span>=<span style="color:#bf0303">"yes"</span><span style="color:#006e28"> type</span>=<span style="color:#bf0303">"numeric"</span><span style="color:#644a9b;font-weight:bold"> /></span> 0097 <span style="color:#644a9b;font-weight:bold"><cfset</span><span style="color:#006e28"> answer</span>=<span style="color:#644a9b;font-weight:bold"> (fahrenheit - 32)*100/180 /></span> 0098 <span style="color:#644a9b;font-weight:bold"><cfreturn answer /></span> 0099 <span style="color:#644a9b;font-weight:bold"></cffunction></span> 0100 <span style="color:#644a9b;font-weight:bold"></cfcomponent></span> 0101 <span style="color:#898887"><!--- test.cfm ---></span> 0102 <span style="color:#644a9b;font-weight:bold"><cfset</span><span style="color:#006e28"> fDegrees</span><span style="color:#644a9b;font-weight:bold"> </span>=<span style="color:#644a9b;font-weight:bold"> 212 /></span> 0103 <span style="color:#644a9b;font-weight:bold"><cfinvoke</span><span style="color:#006e28"> component</span>=<span style="color:#bf0303">"temperature"</span><span style="color:#006e28"> method</span>=<span style="color:#bf0303">"FtoC"</span><span style="color:#006e28"> returnvariable</span>=<span style="color:#bf0303">"result"</span><span style="color:#644a9b;font-weight:bold">></span> 0104 <span style="color:#644a9b;font-weight:bold"><cfinvokeargument</span><span style="color:#006e28"> name</span>=<span style="color:#bf0303">"fahrenheit"</span><span style="color:#006e28"> value</span>=<span style="color:#bf0303">"#fDegrees#"</span><span style="color:#644a9b;font-weight:bold"> /></span> 0105 <span style="color:#644a9b;font-weight:bold"></cfinvoke></span> 0106 <span style="color:#644a9b;font-weight:bold"><cfoutput></span>#fDegrees#<span style="color:#b08000">&deg;</span>F = #result#<span style="color:#b08000">&deg;</span>C<span style="color:#644a9b;font-weight:bold"></cfoutput></span> <span style="font-weight:bold"><br /></span> 0107 0108 <span style="color:#644a9b;font-weight:bold"><cfset</span><span style="color:#006e28"> person</span><span style="color:#644a9b;font-weight:bold"> </span>=<span style="color:#644a9b;font-weight:bold"> CreateObject(</span><span style="color:#bf0303">"component"</span><span style="color:#644a9b;font-weight:bold">, </span><span style="color:#bf0303">"Person"</span><span style="color:#644a9b;font-weight:bold">) /></span> 0109 </pre></body></html>