Top Banner
Select (drop-down list) Inputs
15

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

Jan 17, 2016

Download

Documents

Drusilla Marsh
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: Select (drop-down list) Inputs. Insert/Form/List Menu.

Select (drop-down list) Inputs

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

Insert/Form/List Menu

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

Fill in dialog box

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

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

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

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

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

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

Code View of Select (Drop-down list)

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

Simple select handler code

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

The value of the selected item is passed to the server

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

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

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

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.

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

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

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

Result

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

Another approach using a array

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

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

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

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.