Website Development I

Course Info Class Notes Resources Student Websites

Class No. 21:

Retrieving and Processing Form Responses

Today’s Goal

To continue looking at the powerful things that one can do after one has set up a data structure, and to begin working with HTML forms.

We covered a huge amount of material in our last class.  Today we’re going to revisit and expand on the new topics we looked at.


Class Resources

Web Programming book reading for THIS class

Basic Form and Form Handler, version 2 (Heines)

Web Programming book reading for NEXT class

Same as for this class.


Preambles

Questions from our last class or the readings or work between classes?


Creating and Processing Forms

Review:  Client-Side vs. Server-Side Processing


Source:  https://gillencomputing.wordpress.com/2016/05/24/html-form-processing/

The form Element

Form Child Elements Mentioned in Our Textbook


Source:  Dean, Web Programming, p. 327, fig. 8.6

Additional form Child Elements

form Submission Elements

Examples of Controls and Attributes

Form Example with Processing

This example puts all of the above together:

Basic Form and Form Handler, version 2


Today’s Exercise

Preamble:  This is the same exercise that I introduced in our last class.  I know that most students didn’t have enough time to work on it, so I’m hoping that at least some of you can get to it today.

Goal:  To create a form and process the date that the user enters.

Procedure:

  1. Create an HTML file that contains a simple form.  Don’t try to get too fancy.  Start with just:
  2. Run your program and look at the URL that is generated when you click the Submit button.  Note the search string format.
  3. Add another inupt control to your form with a different type attribute
  4. Run your program again and look at the URL that is generated when you click the Submit button.  Note the change in the search string.
  5. Create a second HTML file the will process the data passed to it in the search string.  Follow the format of the code in the program that was introdued in our last class.
  6. let strSearch = window.location.search ;
    let urlParams = new URLSearchParams( strSearch ) ;
    let strRoomNumber = urlParams.get( "room" ) ;
    let strInstructorName = urlParams.get( "instructor" ) ;
    let strCourseTitle = urlParams.get( "course" ) ;
    let strTimeSlot = arrTimeSlots[ urlParams.get( "timeslot" ) ] ;
  7. Modify the action attribute of your form to go to your new form processing page when the Submit button is clicked.
  8. Test your program to see how the data entered into your form fields can ba processed by your form handler page.


 


This is Class No. 21.  It was last modified on Saturday, October 21, 2023 at 4:38 PM.  Copyright © 2010-2024 by Jesse M. Heines.  All rights reserved, but may be freely copied or excerpted for educational purposes with credit to the author.