Week 4 PowerPoint PPT Presentation

presentation player overlay
1 / 47
About This Presentation
Transcript and Presenter's Notes

Title: Week 4


1
Week 4
2
(No Transcript)
3
(No Transcript)
4
(No Transcript)
5
(No Transcript)
6
(No Transcript)
7
(No Transcript)
8
Action Page
9
(No Transcript)
10
(No Transcript)
11
(No Transcript)
12
Guidelines for creating form pages
13
Creating Action Pages
14
(No Transcript)
15
(No Transcript)
16
Forms
  • You create HTML forms by using the ltFormgt tag
  • The action attribute specifies the name of the
    script or program the web server should execute
    in response to the forms submission.
  • To submit a form to CF, you specify the name of
    the CF template that will process the form.
  • The method Attribute specifies how data is sent
    back to the Web server.
  • All CF forms must be submitted as type POST
  • Listing 12.1
  • Page 304

17
Text
  • The text control is used to capture relatively
    short string input from users.
  • It is good for capturing short text information
    such as names, addresses etc.

18
Text Box
  • First Name
  • ltInput TYPE text Name First_Name
    ValuePut Name Here Size20 MaxLength30gt
  • This form control will create a text control with
    a visual size of 20 and will accept 30 characters
    of input.
  • A variable called Form.Firstname will be passed
    to the action page with a value of put name
    here.

19
(No Transcript)
20
(No Transcript)
21
(No Transcript)
22
(No Transcript)
23
The conditional logic that we write is called an
expression. What procedures to perform if the
condition is true What procedures to perform if
the condition is NOT true
24
The variables do not pass to the action page If
variable exists If variable does not exist we
can
25
(No Transcript)
26
(No Transcript)
27
(No Transcript)
28
(No Transcript)
29
  • ltcfif firstname IS Bengt
  • Whether a variable named Firstname contains the
    value of Ben
  • ltcfif firstname IS NOT Bengt
  • Whether firstname is not Ben.
  • NEQ or Not Equal
  • ltcfif dayofweek(Now()) is 1gt
  • It is the weekend, yeah
  • lt/cfifgt
  • Other operators are supported too. Page 227.

30
(No Transcript)
31
(No Transcript)
32
(No Transcript)
33
(No Transcript)
34
(No Transcript)
35
Isdefined function takes one argument, a variable
of any type and Returns either Yes or No
36
(No Transcript)
37
(No Transcript)
38
(No Transcript)
39
  • ltcfoutputgt
  • ltCFIF form.state IS MA
  • form.state state tax 8.5
  • ltCFELSEIF form.state is VAgt
  • form.state state tax 8.2
  • ltCFELSEgt
  • form.state State Tax Unknown
  • lt/cfoutputgt

The code in this example checks the state entered
by the user. If the user Enter MA the state
tax is 8.5 the tax is 8.2 if he enters
VA. Any other state returns the value of
Unknown.
40
Nesting ltCFIFgt statements
  • ltcfif (var.payment_type IS CC)gt
  • ltcfif (var.cc_type IS Amex)gt
  • Bill to Amex
  • ltcfif (var.cc_type IS Visa)gt
  • Bill to Visa
  • ltcfif (var.cc_type IS Disc)gt
  • Bill to Discover
  • lt/cfifgt
  • ltCFELSEIF (var.payment_type IS PO)gt
  • Purchase order payment
  • ltCFELSEgt
  • Unknown Payment Method
  • lt/CFIFgt

41
  • Every ltCFIFgt must have a matching lt/CFIFgt.
  • Every ltCFIFgt can have a single ltCFELSEgt
  • Every ltCFIFgt can have an unlimited number of
    ltCFELSEIFgt tags.

42
ltCFPARAMgt
  • A way to handle the situation of non existing
    form variables is to use the ltCFPARAMgt tag.
  • This tag will create variables like ltCFSETgt but
    will first perform a conditional test.
  • If the variable does not already exist, ltCFPARAMgt
    WILL CREATE IT and initialize a value.
  • If the variable exists, ltCFPARAMgt does nothing.
  • Page 254

43
ltCFPARAMgt
  • ltCFPARAM nameFirstName DefaultBengt

44
ltCFABORTgt
  • The CFABORT tag stops processing of a page at the
    tag location. ColdFusion simply returns
    everything that was processed before the CFABORT
    tag. CFABORT is often used with conditional logic
    to stop processing a page because of a particular
    condition.
  • Syntax
  • ltCFABORT SHOWERROR"error_message"gt

45
ltselect name"Toppings"gt ltoption
value"pepperoni"gtPepperonilt/optiongt ltoption
value"mushroom"gtMushroomlt/optiongt ltoption
value"cheese"gtExtra Cheeselt/optiongt ltoption
value"anchovy"gtAnchovylt/optiongt lt/selectgt
46
Building Dynamic Select Boxes
ltCFQUERY NAME"q_GetTopping" DATASOURCE"FastTrack
_Solution"gt SELECT FROM
Toppings lt/CFQUERYgt
47
Building Dynamic Select Boxes
ltselect name"Toppings"gt ltCFOUTPUT
QUERY"q_GetTopping"gt ltoption value"q_GetTopping
.Topping_ID"gt q_GetTopping.Topping_Desclt/option
gt lt/CFOUTPUTgt lt/selectgt
Write a Comment
User Comments (0)
About PowerShow.com