Select (drop-down list) Inputs. Insert/Form/List Menu

Preview:

Citation preview

Select (drop-down list) Inputs

Insert/Form/List Menu

Fill in dialog box

Right click on the drop-down list and select List Values

Or just click on the List Values button in the Property Inspector

Add labels (shown) and values (hidden) and click the + button

Code View of Select (Drop-down list)

Simple select handler code

The value of the selected item is passed to the server

Using a switch statement to display different output based on user’s input

The switch statement

• A switch is a fancy version of an if used when there are several “cases” – various situations (sets of statements) that might be executed depending on the outcome of a single value.

switch($session)• In this case there are variations on the text

printed based on the $session variable passed from the user using the POST method.

A case

case "BB1_6_29":print "<p>June 29, 10:00 - 12:00</p>";print "<p>Blackboard Introduction covers the basics to

get one started.</p>";print "<p>Location: Olney 200</p>";break;

• Starts with the keyword case • Followed by the value signaling that case• Followed by the statements to be executed in this case• Followed by the keyword “break” to denote the end of

the case and prevent them from running into each other

Result

Another approach using a array

Arrays

• An array is a set of related variables – in this case the set of strings that might be printed.

• The individual elements of the array are specified by their index or key– It’s usually referred to as an index if you use

a number, e.g. 0, 1, 2, …– It’s usually called a key if you use a string,

e.g. ‘BB1_6_29’, as done here

Specifying an element

print "<p>You have chosen $session.</p> $workshops[$session]";

• In the statement above the code $workshops[$session] refers to the element of the array that has the key that was sent by the user in the POST method.

Recommended