




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main tpoics for the course are mentioned here. What is E-Commerce and its type. Networking Devices. Markup languages. Security issues. Data mining. E-business. Cryptography and public key infrastructure. Electronic Data Exchange. Internet marketing. ERP. This lecture includes: Java, Scripting, Addition, Subtraction, Document, Object, Modification, Html, Script, Language, Function
Typology: Exercises
1 / 8
This page cannot be seen from the preview
Don't miss anything!





Lesson 14 JAVA SCRIPTING (CONTINUED….)
We can also get the result of addition or subtraction written on a page using ‘write’ function of the document object. Again we need to do a slight modification in the code as shown below.
First Number:
Second Number:
When a user types 3 and 9 in the two text boxes, respectively, as shown in Fig. 1 below and presses ‘AddThem!!’ the addition of two nos. ‘12’ is written on a web page (Fig. 2). On clicking ‘Subtract Them!!’ the subtraction of two nos. ‘-6’ is written on a page (Fig. 3). Note that in the brackets of ‘document.write’ we concatenate or join some text information called string (within double quotation marks) with the addition/subtraction of two nos. using ‘+’ sign. The addition/subtraction of nos. is achieved using function ‘parseFloat()’, that is, a function of predefined global object.
Fig. 1
Fig. 2
Fig. 3 Multiply and divide calculator
See the following code:
Multiply and Divide Calculator
First Number:
Second Number:
Result is shown in Fig. 6 below.
Fig. 6
In the above example, event handler ‘onchange’ has been used, having the effect that when an option is selected by the user the control is shifted to the above defined function GoToIt(list). Due to the key word ‘this’ information/list contained in the select tag is available to the argument ‘list’ of the function GoToIt(). When the function would be executed the value of the selected option would be assigned to the variable ‘selection’. Due to location.href=selection, the existing location of the web page is changed to the location of the option/web page that has been selected and that particular web page opens. ‘Location’ is another predefined browser object.
Example - If Statement IF statement in programming is used to alter the course of execution of code depending upon the value of a condition. See the following example:
First Number:
Second Number:
Results are shown in Figures 7 and 8 below.
Fig. 7
Note that using for loop we are able to generate six different levels of headings in HTML.
Some predefined JavaScript objects
A list of some commonly used predefined JavaScript object is given below: Global Array String Math Date Global object is an object with globally-accessible variables/properties and functions. Netscape navigator and internet explorer implement Global object, but do not allow it to be explicitly created or referenced. Instead its properties and methods are referenced directly. NaN - ‘not a number’ is one of its properties. ‘parseFloat(string)’ that parses the string as a floating point number, is the example of a function/method of Global Object. Note a general difference between properties and functions of an object in that the names of the properties are not followed by small brackets whereas the names of the functions do have small brackets following their names. Information contained in the small brackets of a function is called arguments. Also note that generally properties and functions of an object are invoked/referenced by typing the name of the object followed by a dot before typing the property or function name, e.g, document.write().
Array Object also has different properties and functions. ‘Length’ is an important property of this object that identifies the length of the array. Its methods/functions include toString(), reverse(), sort() etc. Array Example
Using Arrays
Using Arrays
Result is shown in Fig. 10 below.
Math object provides a standard library of mathematical constants and functions. Following example shows some properties and methods of this object.
Using the Math object
Using the Math object
Result is shown in Fig. 11 below.
Fig. 11