Page 63 - DCAP408_WEB_PROGRAMMING
P. 63

Unit 2: Creating Static Web Pages




          addition to plain text. Client-side scripts will provide the means to constrain field values and to  Notes
          add new field types.

          Exampel of a form

          This fictitious example is a questionnaire. It uses the INPUT element for simple text fields, radio
          buttons, checkboxes, and the submit and reset buttons. The TEXTAREA field is used for a multi-
          line text entry field. The form fields are laid out with several paragraph elements and an unordered
          list. Notice the use of the NAME attribute to name each field:
                 <html>
                 <TITLE>Sample  Questionaire</TITLE>
                 <H1>Sample  Questionaire</H1>
                 <P>Please  fill  out  this  questionnaire:
                 <FORM  METHOD=post  ACTION=”http://www.hal.com/sample”>
                 <P>Your  name:  <input  name=”name”  size=”48">
                 <P><input  name=”male”  type=radio>  Male
                 <P><input  name=”female”  type=radio>Female
                     Number  in  family:  <input  name=”family”  type=int>
                     <P>Cities  in  which  you  maintain  a  residence:
                 <UL  PLAIN>
                 <LI><input  name=”city”  type=checkbox  value=”delhi”>  delhi
                 <LI><input  name=”city”  type=checkbox  value=”ghaziabad”>  ghaziabad
                 <LI>Others  <textarea  name=”other”  cols=48  rows=4></textarea>
                 </UL>
                 <P>Nickname:  <INPUT  NAME=”nickname”  size  =”42">
                 <P>Thank  you  for  responding  to  this  questionaire.
                 <P><INPUT  TYPE=SUBMIT>  <INPUT  TYPE=RESET>
                 </FORM>
                 </html>
          The output is shown in Figure 2.6.
          Every form must be enclosed within a FORM element. There can be several forms in a single
          document, but the FORM element can’t be nested. The browser is responsible for handling the
          input focus, i.e., which field will currently get keyboard input. Many platforms have existing
          conventions for forms, for example, using Tab and Shift-Tab to move the keyboard focus forwards
          and backwards between fields, and using the Enter (aka Return) key to submit the form.

          This standard defines and requires support for the HTTP access protocol only. Under any protocol,
          the submitted contents of the form logically consist of a list of name/value  pairs where the
          names are given by the NAME attributes of the various fields in the FORM. Each field will
          normally be given a distinct name. Several radio buttons can share the same name, as this is how
          you specify that they belong to the same control group - at any time, only one button in the
          group can be selected.








                                           LOVELY PROFESSIONAL UNIVERSITY                                   57
   58   59   60   61   62   63   64   65   66   67   68