SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 49 | Next

Deepak Vohra

"Ajax in Oracle JDeveloper"


3 Less JavaScript with Prototype
3.1 Introduction
In the previous chapter we discussed the procedure to create an Ajax web
application. The reader might have noticed that the client script included a
lot of JavaScript. Prototype is a JavaScript library for developing dynamic
web applications. The objective of the prototype library is to reduce the
JavaScript code with prototype functions and to provide Ajax functionality
with Ajax.Request and Ajax.Updater classes. In a previous
chapter we developed an Ajax application to validate an input form. The
same application could be developed with the Prototype library, as we
shall discuss in this chapter.
3.2 Overview of Prototype
The Prototype library provides various utility functions to reduce
JavaScript code, and provides Ajax classes to send an
XMLHttpRequest request. Prototype also provides functions for DOM
processing, form processing, and event processing. We shall discuss the
main Prototype functions and classes next.
3.2.1 $() function
The $() function is used to replace the
document.getElementById() function. For example a nonprototype
JavaScript retrieves a form element formDiv as follows.
var formDiv =document.getElementById(???formDiv???);
The formDiv element may be retrieved with prototype as follows.
var formDiv =$('formDiv');
46 3 Less JavaScript with Prototype
3.2.2 $F() function
The $F()function is used to retrieve the value of a form element.


Pages:
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61