Top Banner
1 Chapter 5 Chapter 5 Dynamical Calculations Dynamical Calculations
19
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Dynamic Web Pages Ch 5 V1.0

1

Chapter 5Chapter 5Chapter 5Chapter 5

Dynamical CalculationsDynamical Calculations

Page 2: Dynamic Web Pages Ch 5 V1.0

2

Overview• In this chapter you will:

– Dynamically populate a drop-down menu.

– Create a recordset using a filter from the form data on the previous asp page.

– Insert dynamic text.– Write the code to handle errors when

data has not validated.

Page 3: Dynamic Web Pages Ch 5 V1.0

3

Dynamically populated drop-down menus.

The next activity will create a drop-down menu which is populated from the database through a recordset.

tourprice.php

Page 4: Dynamic Web Pages Ch 5 V1.0

4

Dynamic calculation • Remember the Tour Calculator.• We are going to change it to

dynamically put the tour locations in the list/menu, (with the ID being the value) on the tourprice.php page.

• On the tourprice_processor.php, we will then use the id to select the adult and child rate to calculate the cost or the tour.

Page 5: Dynamic Web Pages Ch 5 V1.0

5

Create a tourprice recordset

Test the recordset

View the sql statement with the advanced button.

Page 6: Dynamic Web Pages Ch 5 V1.0

6

Dynamic drop-down• Open tourprice.php page and

select the list/menu.• Select the dynamic button.• Remove the static labels and

values with the – button.

Page 7: Dynamic Web Pages Ch 5 V1.0

7

• Fill the dialog as shown.

Dynamic drop-down-2

Page 8: Dynamic Web Pages Ch 5 V1.0

8

• Save and view as shown.

Dynamic drop-down-3

Page 9: Dynamic Web Pages Ch 5 V1.0

9

Next Activity: Creating dynamic text

tourprice.php

tourprice_processor.php

Click on the submit button.

The data in the form is transferred to the tourprice_processor.php page. The price is calculated using the form data.

Dynamic text

Page 10: Dynamic Web Pages Ch 5 V1.0

10

• Open tourprice_processor.php page.• Create a new recordset (shown on

next slide), with the following attributes: – Name = rsTourpricesFiltered – Connection = conn_newland– Table = tours – Columns = selected tourID, tourName,

basePriceAdult, basePriceChild

Dynamic calculation

Page 11: Dynamic Web Pages Ch 5 V1.0

11

• Click the Test button. Enter 9 in the Please Provide a Test Value dialog, and click OK.

• Click OK to exit the test output, and again to save the recordset.

Filtered recordset

Note: This recordset has a filter on it. The recordset will only select a tour id that equals tour is that was selected from the pervious asp page.

Page 12: Dynamic Web Pages Ch 5 V1.0

12

• Place xx as shown.• Highlight xx.• Select Dynamic

Text as shown.• The dialog shown

appears, select tourName and click OK.

Displaying dynamic text

Page 13: Dynamic Web Pages Ch 5 V1.0

13

• Delete the code that sets the base price.

• Add the following lines

Fixing up the price.

Page 14: Dynamic Web Pages Ch 5 V1.0

14

• Save and view the pages.

Save and view

Page 15: Dynamic Web Pages Ch 5 V1.0

15

Lab 5 - 1• In this lab you will;

– Create a dynamic list/menu for the reservation.php page, shown on the next slide.

– Add a dynamic feature tour list, as shown on the following slides. • To do this you need to detach this page

from the template.

Page 16: Dynamic Web Pages Ch 5 V1.0

16

Lab 5 - 2

Reservation.php

Dynamic tour list•Note: Duplicate entries because the same trip is offered on different dates.

Page 17: Dynamic Web Pages Ch 5 V1.0

17

Lab 5 – 3 reservation.php

Static Featured tours

Dynamic Feature tours

The reservation page has static values for the “Featured Tours” data. In this lab you are going to change it from static to dynamic.

Page 18: Dynamic Web Pages Ch 5 V1.0

18

Lab 5 - 4• reservations.php page. • create a recordset

– named rs_tours from the tours table. – Select only TourID, TourName, and TourDate – sort by TourName.

• Click the Dynamic button in the Property inspector. – Dynamically fill the values from the recordset

that you just created. The values are the TourID

– Labels are the TourName – Click OK to close the dynamic dialog.

• Save the page and preview it. Drop down the list to see the dynamic values.

Page 19: Dynamic Web Pages Ch 5 V1.0

19

Lab 5 - 5• Create a recordset• Delete the text under

the Featured Tours heading.

• Add a dynamic table as shown. Remember border=0. Save and view.