You've learned some technical details as to why JavaScript is important, but what's it really good for? What will it do for your Web pages? The following sections present some of the most important uses for JavaScript.
Including Dynamic Information
JavaScript can be used to add a bit of life to a Web page by making some of the text dynamic. As a simple example, you could display an appropriate greeting-"good morning" or "good evening", depending on the time. Because you can use and control the HTML itself, you can extend this by dynamically choosing graphics or links using JavaScript. Thus, depending on the user, the time, or any factor, you can present the appropriate page.
Validating Forms
You've seen forms at many Web pages, and probably used them yourself. The user enters data into the form, then presses the Submit button, and the server, using a CGI program, responds to the information. This is useful, but it isn't very interactive-before you can receive a response, you have to wait for the data to travel to the server and back.
Note |
The biggest difference between JavaScript and CGI is that CGI works on the server and JavaScript works on the user's own machine (the client). CGI is most useful for sending data to the server and sending server data back to the user. |
JavaScript can add instant gratification to a Web form. You still can't send the data to the server until the Submit button is pressed, but JavaScript can act on the data in the meantime. For example, you could fill out a loan application online and, as you fill it out, instantly get feedback about the kind of payments the loan will require. After you're satisfied with the application, you can then submit it to the server.
Making Pages Interactive
Finally, JavaScript can be used to remove some of the drudgery from a normal Web page by giving the user some control of the page. For example, you could have a background on/off button to control the display of the background, or a button to toggle the display of a table of contents.
----------------------------------------------------------
** If you like this post please like our page in facebook
0 comments:
Post a Comment