Creating Forms - 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

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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











  • Creating Forms


    Before you can create a search form, you need to learn how ColdFusion interacts wit263 forms.


    <!---
    Name: forms.cfm
    Author: Ben Forta (ben@forta.com)
    Description: Introduction to forms
    Created: 12/20/04
    --->
    &l275>
    <head>
    <title>Learning ColdFusion Forms 1</title>
    </head>
    <body>
    <!--- Movie search form --->
    <form action="form1_action.cfm" method="POST">
    Please enter the movie name and then click
    <strong>Process</strong>.
    <p>
    Movie:
    <input type="text" name="MovieTitle">
    <br>
    <input type="submit" value="Process">
    </form>
    </body>
    </html>

    Execute this code to display the form, as shown in


    You creat260 forms by using the <form> tag. <form> usually takes two parameters passed as tag attributes. The action attribute specifies the name of the script or program that the Web server should execute in response to the form's submission. To submit a form to ColdFusion, you specify the name of the ColdFusion template that will process the form. The following example specifies that the template form1_action.cfm should process the submitted form:


    action="form1_action.cfm"

    The method attribute specifies how data is sent back to the Web server. As a rule, all ColdFusion forms should be submitted as type post.

    CAUTION


    The default submission type is not post; it is usually get. If you omit the method="post" attribute from your form tag, you run the risk of losing form data, particularly in long forms or forms with textarea controls.

    Your form has only a single data entry field: <input type="text" name="MovieTitle">. This is a simple text field. The name attribute in the <input> tag specifies the name of the field, and ColdFusion uses this name to refer to the field when it is processed.

    Each field in a form is usually given a unique name. If two fields have the same name, both sets of values are returned to be processed and are separated by a comma. You usually want to be able to validate and manipulate each field individually, so each field should have its own name. The notable exceptions are the check box and radio button input types, which we'll describe shortly.

    The last item in the form is an <input> of type submit. The submit <input> type creates a button that, when clicked, submits the form contents to the Web server for processing. Almost every form has a submit button (or a graphic image that acts like a submit button). The value attribute specifies the text to display within the button, so <input type="submit" value="Process"> creates a submit button with the text Process in it.

    TIP

    When you're using an input type of submit, you should always specify button text by using the value attribute. If you don't, the default text Submit Query (or something similar) is displayed, which is likely to confuse your users.

    Form Submission Error Messages


    If you enter a movie title into the field and submit the form right now, you will receive a ColdFusion error message like the one in Figure 12.2. This error says that file form1_action.cfm can't be found.

    Figure 12.2. ColdFusion returns an error message when it can't process your request.

    [View full size image]

    This error message is perfectly valid, of course. You submitted a form to be passed to ColdFusion and processed it with a template, but you haven't created that template yet. So your next task is to create a template to process the form submission.


  • / 281