

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Javascript
Adds scripting functions to a webpage
Denotes beginning and end of script Attributes: LANGUAGE=”JAVASCRIPT”
FUNCTION Create a function
Syntax: function functionname(inputvariables) { operations performed }
VAR Creates a variable
Syntax: var variablename=variablevalue;
A variable value can take multiple forms, but in order to complete the assignments for today we’ll only look at a couple of examples. var example=new Array (0,1,2,3,4,5,6); creates a variable called example which is an array of numbers var formitem=myForm.drop.selectedIndex; creates a variable called formitem which takes the value of the index(1=1st, 2=2nd, 3=3rd, etc) of the selected option from the selection named drop in the form named myForm. var sum=12+example[formitem]; creates the variable named sum which equals 12 + the element of the array example designated by the value of formitem. If formitem=4, example[4]=3, so sum=15.
DOCUMENT outputs data to the html document. i.e. can be used to change attribute values within an html document.
document.bob.bobsText.value=”#”+sum; the value of the text input named bobsText in the form named bob will be
changed to “#” + sum, or from previous example: #
Javascript events
Used to execute a script. They are an attribute that can be added to HTML tags. i.e. onAbort, onBlur, onChange, onClick, etc…
onClick When the item is clicked with the mouse, the specified script function is executed.
Example:
Creates form named “bob”, and a button labeled “Click Me”. When button is clicked, the function bobsFunction is executed and the data in the form bob is passed as a variable.
Assignment: Campus Computers Using Tables, Forms, and Javascript recreate the webpage called Campus Computers shown below
For “Select RAM Memory” the other options are: “32 Mb add $49”, “64 Mb add $98”, and “96 Mb add $159”
For “Select Hard Drive” the other options are: “4.0 Gig HD add $109”, “6.2 Gig HD add $179”, “8.2 Gig HD add $219”, and “11.4 Gig HD add $299”.
For “Select Modem or NIC” the other options are: “56K V90 or X2 Modem add $109”, “10/100 NIC add $79”, and “Combo Modem and NIC add $279”.
When “Price” is clicked, the new price will be calculated and displayed in the textbox next to “The new calculated price:”. If no upgrades are selected and “Price” is clicked, the price should be “$799”, if upgrades are selected “The new calculated price” should reflect the increased price when “Price” is clicked..