Trying It Yourself - macromedia COLDFUSION MX 7 Web Application Construction Kit [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

macromedia COLDFUSION MX 7 Web Application Construction Kit [Electronic resources] - نسخه متنی

Ben Forta, Raymond Camden, Leon Chalnick, Angela Buraglia

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











  • Trying It Yourself


    Codegen is OK for some tasks (and is wonderful for rapid prototyping), but more often than not it won't be enough. This is why most of this book discusses coding. To give you a taste of what's to come, try this small (and very simple) application. I won't go into the details of the code itself; for now, concentrate on creating and executing CFM files so they work. If you can get all these to function, you'll have a much easier time working through the book.

    The bday application is really simple; it prompts you for your name and date of birth and calculates your age, using simple date arithmetic. The application is made up of two files:

    • bday1.cfm
      (shown in Listing 4.1) is the form that prompts for the name and date of birth.

    • bday2.cfm
      (shown in Listing 4.2) processes the form and displays the results.


    Using Dreamweaver MX, create these two new files, saving them both in the 4 directory. Then enter the code below in each file exactly as it appears hereyour files should contain this code and nothing else.

    Listing 4.1. bday1.cfm


    &l275>
    <body>
    <form action="bday2.cfm" method="post">
    Name: <input type="text" name="name">
    <br>
    Date of birth: <input type="text" name="dob">
    <br>
    <input type="submit" value="calculate">
    </form>
    </body>
    </html>

    The code in bday1.cfm is simpl260there's no ColdFusion code at all. In fact, you could have named the file with a269 extension and it would have worked properly.

    bday1.cfm contains a269 form with two form fields: name for the user name and dob for the date of birth.

    Listing 4.2. bday2.cfm


    &l275>
    <body>
    <cfoutput>
    Hello #FORM.name#,
    you are #DateDiff("YYYY", FORM.dob, Now())#.
    </cfoutput>
    </body>
    </html>

    The code in bday2.cfm is a mixture o261 and CFML. The name form field displays the Hello message, and the dob field calculates the age.

    To try the application, open a browser and go to the following URL:


    http://localhost:8500/ows/4/bday1.cfm


    [View full size image]

    Figure 4.19. ColdFusion generates output displayed in a browser.

    [View full size image]

    Was that a little anticlimactic after the Dreamweaver MXgenerated application? Perhaps. But you've now learned all you need to know about creating, saving, and executing ColdFusion applications.


  • / 281