110 lines
12 KiB
HTML
110 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html><head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
<title>highlight.cfml</title>
|
|
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (ColdFusion) - Theme (Breeze Dark)"/>
|
|
</head><body style="background-color:#232629;color:#cfcfc2"><pre>
|
|
<span style="color:#7a7c7d"><!--- ColdFusion Sample File ---></span>
|
|
<span style="color:#7a7c7d"><!--- Source: https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/using-arrays-and-structures/structure-examples.html ---></span>
|
|
|
|
<span style="font-weight:bold"><head></span>
|
|
<span style="font-weight:bold"><title></span>Add New Employees<span style="font-weight:bold"></title></span>
|
|
<span style="font-weight:bold"></head></span>
|
|
|
|
<span style="font-weight:bold"><body></span>
|
|
<span style="font-weight:bold"><h1></span>Add New Employees<span style="font-weight:bold"></h1></span>
|
|
<span style="color:#7a7c7d"><!--- Action page code for the form at the bottom of this page. ---></span>
|
|
|
|
<span style="color:#7a7c7d"><!--- Establish parameters for first time through ---></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfparam</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"Form.firstname"</span><span style="color:#27ae60"> default</span>=<span style="color:#f44f4f">""</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfparam</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"Form.lastname"</span><span style="color:#27ae60"> default</span>=<span style="color:#f44f4f">""</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfparam</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"Form.email"</span><span style="color:#27ae60"> default</span>=<span style="color:#f44f4f">""</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfparam</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"Form.phone"</span><span style="color:#27ae60"> default</span>=<span style="color:#f44f4f">""</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfparam</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"Form.department"</span><span style="color:#27ae60"> default</span>=<span style="color:#f44f4f">""</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
|
|
<span style="color:#7a7c7d"><!--- If at least the firstname form field is passed, create</span>
|
|
<span style="color:#7a7c7d">a structure named employee and add values. ---></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfif #Form.firstname# eq </span><span style="color:#f44f4f">""</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
<span style="font-weight:bold"><p></span>Please fill out the form.<span style="font-weight:bold"></p></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfelse></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfoutput></span>
|
|
<span style="color:#da4453;font-weight:bold"><cfscript></span>
|
|
employee<span style="font-weight:bold">=</span><span style="color:#8e44ad;font-weight:bold">StructNew</span><span style="font-weight:bold">()</span>;
|
|
employee.firstname <span style="font-weight:bold">=</span> Form.firstname;
|
|
employee.lastname <span style="font-weight:bold">=</span> Form.lastname;
|
|
employee.email <span style="font-weight:bold">=</span> Form.email;
|
|
employee.phone <span style="font-weight:bold">=</span> Form.phone;
|
|
employee.department <span style="font-weight:bold">=</span> Form.department;
|
|
<span style="color:#da4453;font-weight:bold"></cfscript></span>
|
|
|
|
<span style="color:#7a7c7d"><!--- Display results of creating the structure. ---></span>
|
|
First name is #StructFind(employee, "firstname")#<span style="font-weight:bold"><br></span>
|
|
Last name is #StructFind(employee, "lastname")#<span style="font-weight:bold"><br></span>
|
|
EMail is #StructFind(employee, "email")#<span style="font-weight:bold"><br></span>
|
|
Phone is #StructFind(employee, "phone")#<span style="font-weight:bold"><br></span>
|
|
Department is #StructFind(employee, "department")#<span style="font-weight:bold"><br></span>
|
|
<span style="color:#8e44ad;font-weight:bold"></cfoutput></span>
|
|
|
|
<span style="color:#7a7c7d"><!--- Call the custom tag that adds employees. ---></span>
|
|
<span style="color:#2980b9;font-weight:bold"><cf_addemployee</span><span style="color:#27ae60"> empinfo</span>=<span style="color:#f44f4f">"#employee#"</span><span style="color:#2980b9;font-weight:bold">></span>
|
|
<span style="color:#8e44ad;font-weight:bold"></cfif></span>
|
|
|
|
<span style="color:#7a7c7d"><!--- The form for adding the new employee information ---></span>
|
|
<span style="font-weight:bold"><hr></span>
|
|
<span style="font-weight:bold"><form</span><span style="color:#27ae60"> action</span>=<span style="color:#f44f4f">"newemployee.cfm"</span><span style="color:#27ae60"> method</span>=<span style="color:#f44f4f">"Post"</span><span style="font-weight:bold">></span>
|
|
First Name:<span style="color:#c45b00">&nbsp;</span>
|
|
<span style="font-weight:bold"><input</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"firstname"</span><span style="color:#27ae60"> type</span>=<span style="color:#f44f4f">"text"</span><span style="color:#27ae60"> hspace</span>=<span style="color:#f44f4f">"30"</span><span style="color:#27ae60"> maxlength</span>=<span style="color:#f44f4f">"30"</span><span style="font-weight:bold">><br></span>
|
|
Last Name:<span style="color:#c45b00">&nbsp;</span>
|
|
<span style="font-weight:bold"><input</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"lastname"</span><span style="color:#27ae60"> type</span>=<span style="color:#f44f4f">"text"</span><span style="color:#27ae60"> hspace</span>=<span style="color:#f44f4f">"30"</span><span style="color:#27ae60"> maxlength</span>=<span style="color:#f44f4f">"30"</span><span style="font-weight:bold">><br></span>
|
|
EMail:<span style="color:#c45b00">&nbsp;</span>
|
|
<span style="font-weight:bold"><input</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"email"</span><span style="color:#27ae60"> type</span>=<span style="color:#f44f4f">"text"</span><span style="color:#27ae60"> hspace</span>=<span style="color:#f44f4f">"30"</span><span style="color:#27ae60"> maxlength</span>=<span style="color:#f44f4f">"30"</span><span style="font-weight:bold">><br></span>
|
|
Phone:<span style="color:#c45b00">&nbsp;</span>
|
|
<span style="font-weight:bold"><input</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"phone"</span><span style="color:#27ae60"> type</span>=<span style="color:#f44f4f">"text"</span><span style="color:#27ae60"> hspace</span>=<span style="color:#f44f4f">"20"</span><span style="color:#27ae60"> maxlength</span>=<span style="color:#f44f4f">"20"</span><span style="font-weight:bold">><br></span>
|
|
Department:<span style="color:#c45b00">&nbsp;</span>
|
|
<span style="font-weight:bold"><input</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"department"</span><span style="color:#27ae60"> type</span>=<span style="color:#f44f4f">"text"</span><span style="color:#27ae60"> hspace</span>=<span style="color:#f44f4f">"30"</span><span style="color:#27ae60"> maxlength</span>=<span style="color:#f44f4f">"30"</span><span style="font-weight:bold">><br></span>
|
|
|
|
<span style="font-weight:bold"><input</span><span style="color:#27ae60"> type</span>=<span style="color:#f44f4f">"Submit"</span><span style="color:#27ae60"> value</span>=<span style="color:#f44f4f">"OK"</span><span style="font-weight:bold">></span>
|
|
<span style="font-weight:bold"></form></span>
|
|
<span style="font-weight:bold"><br></span>
|
|
<span style="font-weight:bold"></body></span>
|
|
<span style="font-weight:bold"></html></span>
|
|
|
|
<span style="color:#8e44ad;font-weight:bold"><cfoutput></span>
|
|
Error. No employee data was passed.<span style="font-weight:bold"><br></span>
|
|
<span style="color:#8e44ad;font-weight:bold"></cfoutput></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfexit</span><span style="color:#27ae60"> method</span>=<span style="color:#f44f4f">"ExitTag"</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfelse></span>
|
|
<span style="color:#7a7c7d"><!--- Add the employee ---></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfquery</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"AddEmployee"</span><span style="color:#27ae60"> datasource</span>=<span style="color:#f44f4f">"cfdocexamples"</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
INSERT INTO Employees
|
|
(FirstName, LastName, Email, Phone, Department)
|
|
VALUES (
|
|
'#attributes.empinfo.firstname#' ,
|
|
'#attributes.empinfo.lastname#' ,
|
|
'#attributes.empinfo.email#' ,
|
|
'#attributes.empinfo.phone#' ,
|
|
'#attributes.empinfo.department#' )
|
|
<span style="color:#8e44ad;font-weight:bold"></cfquery></span>
|
|
<span style="color:#8e44ad;font-weight:bold"></cfif></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfoutput></span>
|
|
<span style="font-weight:bold"><hr></span>Employee Add Complete
|
|
<span style="color:#8e44ad;font-weight:bold"></cfoutput></span>
|
|
|
|
<span style="color:#7a7c7d"><!--- temperature.cfc ---></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfcomponent></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cffunction</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"FtoC"</span><span style="color:#27ae60"> access</span>=<span style="color:#f44f4f">"public"</span><span style="color:#27ae60"> returntype</span>=<span style="color:#f44f4f">"numeric"</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfargument</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"fahrenheit"</span><span style="color:#27ae60"> required</span>=<span style="color:#f44f4f">"yes"</span><span style="color:#27ae60"> type</span>=<span style="color:#f44f4f">"numeric"</span><span style="color:#8e44ad;font-weight:bold"> /></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfset</span><span style="color:#27ae60"> answer</span>=<span style="color:#8e44ad;font-weight:bold"> (fahrenheit - 32)*100/180 /></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfreturn answer /></span>
|
|
<span style="color:#8e44ad;font-weight:bold"></cffunction></span>
|
|
<span style="color:#8e44ad;font-weight:bold"></cfcomponent></span>
|
|
<span style="color:#7a7c7d"><!--- test.cfm ---></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfset</span><span style="color:#27ae60"> fDegrees</span><span style="color:#8e44ad;font-weight:bold"> </span>=<span style="color:#8e44ad;font-weight:bold"> 212 /></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfinvoke</span><span style="color:#27ae60"> component</span>=<span style="color:#f44f4f">"temperature"</span><span style="color:#27ae60"> method</span>=<span style="color:#f44f4f">"FtoC"</span><span style="color:#27ae60"> returnvariable</span>=<span style="color:#f44f4f">"result"</span><span style="color:#8e44ad;font-weight:bold">></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfinvokeargument</span><span style="color:#27ae60"> name</span>=<span style="color:#f44f4f">"fahrenheit"</span><span style="color:#27ae60"> value</span>=<span style="color:#f44f4f">"#fDegrees#"</span><span style="color:#8e44ad;font-weight:bold"> /></span>
|
|
<span style="color:#8e44ad;font-weight:bold"></cfinvoke></span>
|
|
<span style="color:#8e44ad;font-weight:bold"><cfoutput></span>#fDegrees#<span style="color:#c45b00">&deg;</span>F = #result#<span style="color:#c45b00">&deg;</span>C<span style="color:#8e44ad;font-weight:bold"></cfoutput></span> <span style="font-weight:bold"><br /></span>
|
|
|
|
<span style="color:#8e44ad;font-weight:bold"><cfset</span><span style="color:#27ae60"> person</span><span style="color:#8e44ad;font-weight:bold"> </span>=<span style="color:#8e44ad;font-weight:bold"> CreateObject(</span><span style="color:#f44f4f">"component"</span><span style="color:#8e44ad;font-weight:bold">, </span><span style="color:#f44f4f">"Person"</span><span style="color:#8e44ad;font-weight:bold">) /></span>
|
|
</pre></body></html>
|