[ Pobierz całość w formacie PDF ]
." End If End Sub--></SCRIPT></BODY></HTML>Notice that the textarea is used to enter the user's address,which could eventually be printed on a mailing label.You couldsubmit the user's name to a server, along with the credit cardnumber (in a secure fashion, of course) and the total cost.Thecredit card number is restricted to 19 spaces, which includesfour sets of four numbers plus three spaces.The button controltriggers a script.The script also has some very simple validation code to make surethe user enters all the required information.This validationcode could be much more sophisticated, but it serves its purposehere.You could add even more validation code and then triggera special form method called Submitthat would send the data to a CGI script program on the server,which would actually process the data.The message box that appearsto the user could, in reality, be a Web page that the server sendsback to the user with order information.To keep the code clearand simple, the actual submittal code was not included with thisexample.You will learn more about that process on Day 19.SummaryToday's lesson presents you with three intrinsic HTML form controls:the button control, the text control, and the textarea control.Each of these controls, traditionally called form input controls,are defined by the HTML standard and usually used in conjunctionwith an HTML form.You have learned what an HTML form is, as wellas how it is used, which helped better define what a "formcontrol" is.Because these controls are intrinsic to HTMLand browsers, they do no not need to be "registered"or "loaded" into the program as OLE and ActiveX controlsand components do.You'll learn more about those on Day 10.You have learned how to create button controls and place themon a Web page.Furthermore, you have learned how to hook up codein VBScript Web pages by using event procedures.Today's lessonalso presented the text and textarea controls, and you learnedhow define and place them on a Web page.The user can use theVALUE property of these controlsin VBScript to send and retrieve information to a text control.For more information on HTML, refer to one of the resources mentionedtoday and in Appendix B, "Information Resources." Tomorrow,you will learn about some of the other popular HTML form controls.By then, you will have a good, working knowledge of all thesecontrols.Once you've also learned ActiveX controls, you willbe able to present very powerful Web pages to your users.Q&AQWhat is the difference between ActiveX controls and HTML controls?AThe main difference between the two is that HTML controls are defined as part of the HTML language standard.ActiveX controls are extras that you can add to a Web page but are not part of HTML.The ActiveX control standard that was created by Microsoft can give the programmer more powerful and capable controls than what HTML controls provide.HTML controls provide many of the fundamental controls that you use every day such as the text controland the button.ActiveX controls add extra pizzazz to your Web pages by providing you services that take you beyond the conventional HTML controls such as fancy labels that can be displayed at an angle.QWhy can't I have better control over the placement and size of the controls as I can in Visual Basic?AThe whole philosophy behind HTML is that it enables the browser to do the formatting for you.Any control based on HTML adheres strongly to that principle.For example, you cannot adjust thesize of a button; the browser does it for you.You can set the length of the text control, and the textarea properties enable you to specify the dimensions of the control.However, you cannot specify X and Y coordinates for placing controls on a page.Youmust adhere to the HTML standards.QAre there any limits to the amount of text the user can enter in a textarea control?AThere is a limit, but it's pretty large.The current limit is approximately 65,000 characters.The user is not likely to enter that much information, however.If he wants to send information ofthat magnitude, a better approach might be to provide him with the capability to FTP a file directly to the server rather than work through a textarea control on a Web page.WorkshopCreate a Web page that uses each of the controls presented today.Make the goal of your Web page to get information from the userfrom various text fields.Do you find that text and textarea controlsare adequate to get what you want from the user? What are theadvantages of the text and textarea controls? What are their disadvantages?QuizNoteRefer to Appendix C, "Answers to Quiz Questions," for the answers to these questions.How is the textarea control different from the text control?Write a Web page where the user must enter a list of productsthat he wants more information about from your company.Don'tforget to give him a way to tell you he is finished entering theproducts and ready to get the information.Don't worry about supplyingthe piece of this page that communicates to the server; just providethe portion that collects the data
[ Pobierz całość w formacie PDF ]