Presentation is loading. Please wait.

Presentation is loading. Please wait.

Other types of input element There are some types of input element that we have not considered: –type='image’ –type='hidden’ We will delay dealing with.

Similar presentations


Presentation on theme: "Other types of input element There are some types of input element that we have not considered: –type='image’ –type='hidden’ We will delay dealing with."— Presentation transcript:

1 Other types of input element There are some types of input element that we have not considered: –type='image’ –type='hidden’ We will delay dealing with these until later

2 Other user-input elements So far we have considered two classes of user-input elements: –the button element –the input element There are two other kinds: –the select element –the textarea element

3 The select element This type of element merely offers another way of capturing the kinds of user-selection that we have already seen how to capture with the input elements of type=‘checkbox’ and of type=‘radio’ Consider the web page on the following slide

4

5 By clicking on the down-arrow, the user sees a range of options

6 This is implemented as follows : T-shirt Order form Order What is your name? Sorry! Each order is limited to one T-shirt. select the one you want: Batman's cloak Superman's cloak Dr. Who's coat Form Submission Submit order

7 select element vs. input element of type='radio The following select element Batman's cloak Superman's cloak Dr. Who's coat is equivalent to the following group of input elements: Batman's cloak Superman's cloak Dr. Who's coat They both allow ONLY ONE selection

8 Allowing multiple selections If we use the atttribute multiple in the select tag, multiple selections are allowed: Batman's cloak Superman's cloak Dr. Who's coat See the next slide

9

10 Preselection

11 This is done as follows: Batman's cloak Superman's cloak (our best-selling item) Dr. Who's coat

12 Preselection when only one selection is allowed Consider the following: Batman's cloak Superman's cloak (our best-selling item) Dr. Who's coat Notice, on the next slide, that the Superman shirt is shown as a default, even though the Batman shirt is first in the list above

13

14 What happens when the user moves to the T-shirt selection part of the form:

15 Sizing the selection box So far, the size of the selection box on the form has been determined by default by the browser However, we can specify a size explicitly if we wish: Batman's cloak Superman's cloak (our best-selling item) Dr. Who's coat See what results on the next slide

16

17 The textarea element With this element, we can allow the user to give us free-form feedback Consider the following web page and what happens when the user fills it in as shown on the following slides

18

19

20

21 How it was done: Feedback What do you think of our products? type your answer here … A textarea is delimited by two tags: textarea and /textarea The textarea tag has a name attribute and may have attributes which specify the size of the text-entry box -- but the user’s text can be much larger than this The text between the two tags is the initial text that appears in the text-entry box.

22 The remaining types of input element Now we can consider the input element that we did not consider before: –type='hidden’ –type='image’

23 input of type='hidden’ This has many purposes One common use is to avoid confusing a user by –hiding data which the server needs –but which the user does not need to see For example, in the following interaction, we want to hide the ID number of the item being edited

24 Example usage, slide#1 In the select element below, each option is of the form someName When the user clicks on the submit sutton, it is the ID, not the name, which is sent to the server

25 Example usage, slide#2 Below, the user has selected Al Jazeera –its ID is 1053, but the user cannot see it When the user clicks the submit button, the information sent to the server is producerID=1053

26 Example usage, slide#3 Below, the user can change –the spelling of the TV station’s name, in the input element of type=‘text’ –the paragraph of information about the TV station, in the textarea element But the ID number of the TV station must also be sent to the server when the submit button is clicked So the ID number must be on the form To avoid confusing the user, the ID number is in a hidden element

27 Source code for page on previous slide Notice the input element of type=‘hidden’ –Near the bottom of the source code Just above the button element

28 input of type='image’ This is for using pictures to create submit buttons It is not an element that I like to use –Later, we will see that its effect can be achieved by using JavaScript But, in case you see other people use it, I will give an example of using it here

29 Using an input of type=''image' form { width : 400; background-color:gray; padding:0.1in} legend { color : white }.myImage { height:25; width:25 } <?php $surname=$_POST['surname']; if ($surname) {echo "Your surname is $surname";} else {?> "> What is your surname? Submit data <?php } ?> Example program

30 Fresh form We can see the input element of type=‘text’ And, instead of a submit button, we see an image

31 The user enters his name and....

32 The user enters his name and clicks on the image and …

33 The user enters his name and clicks on the image and the name is sent to the server, which replies


Download ppt "Other types of input element There are some types of input element that we have not considered: –type='image’ –type='hidden’ We will delay dealing with."

Similar presentations


Ads by Google