in black and white
Main menu
Home About us Share a book
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

Javascript for dummies. Quick Reference - Vander

Vander Javascript for dummies. Quick Reference - Wiley Publishing, 2002. - 115 p.
Download (direct link): javascriptquickreference2002.pdf
Previous << 1 .. 20 21 22 23 24 25 < 26 > 27 28 29 30 31 32 .. 72 >> Next

Invoking button methods:
document.myForm.i i ck()
// used to click the button programmatically
L I document
A checkbox object creates — well, a check box. A check box is like a toggle switch — its value is always either off or on.
Creating a check box:
<INPUT TYPE="checkbox" NAME="jazzCheckbox"
VALUE="checkedJazz" CHECKED
onClick="display(this)"> Click here if you like jazz.
In this example, the name of the check box is j azzCheckbox. The value is “checkedJazz” (which is the value that is submitted to the CGI program if the check box is checked). The checkbox is automatically checked the first time that it appears to the user; the text that appears next to the check box is “Click here if you like jazz.”
Accessing check box properties: Form.jazzCheckbox.checked Form.jazzCheckbox.defaultChecked Form.jazzCheckbox.type Form.jazzCheckbox.value
Invoking check box methods: ick()
// used to set checkbox programmatically
r!1 V
A document object defines characteristics of the overall body of a Web page, such as the background color of a page, the default text color, and so on.
Creating a document:
<B0DY BGC0L0R="1ime" TEXT="maroon"
LINK="purple" ALINK="yel1ow" VLINK="blue" onLoad="welcome()" onllnl oad="goodbye() "> </B0DY>
60 file Up toad
The preceding code creates a Web page with a lime-colored background (yecch!) and maroon text. Link text appears purple at first, changes to yellow when a user clicks on the link, and then turns blue after the linked URL has been loaded. As you can see from the last two code statements, when the Web page is first loaded, the wel come () method is invoked automatically; when a user closes the Web page, the goodbye () method is invoked.
Accessing document properties:
document.anchors[0] // array of this document's anchors document.bgColor document.cookie document.fgColor
document.forms[index] // array of this document's forms
document.1astModi fied document.1i nkColor
document.1inks[index] // array of this document's links document.1ocati on document.referrer document.ti tle document.vli nkColor
Invoking document methods: ear()
document.write("Some text here")
document.writeln("Some more text here")
AfileUpload object consists of a Browse button and a text field. To specify a file name, users can either click on the Browse button and choose from the displayed list of files, or enter a filename directly into the text field.
Creating a fileUpload object:
<IN P UT TYPE="fi1e" NAME="myFi1eName">
Accessing fileUpload properties: Form.myFileUpload.type Form.myFileUpload.value
Invoking fileUpload methods:
The f i 1 eUpl oad object has no associated methods.
frame б 1

In Netscape Navigator 3.0, the f i 1 eUpl oad object is read-only (you can’t change its properties).
A form is used to gather input from users and to post data (including user input) to a server for additional processing.
Creating a form:
<F0RM NAME="myForm" METH0D="POST" TARGET="_parent" ACTI0N="http://a 1tavi sta.di gital .com/egi-bin/ query?pg=q&what=web&fmt=.&q=JavaScri pt" ENCTYPE="multi part/form-data" onSubmit="return verifyComplete()">
Accessing form properties:
document.myForm.action document.myForm.elements[0].name Form.elements[0].value Form.encodi ng document.myForm.1ength Form.method
document.forms[0]// first form defined in the document
document.forms.1ength //total # forms defined
Invoking form methods:
document.myForm.reset() document.myForm.submit()
A frame is a special kind of window. You can think of a frame as an individual pane of glass — that is, you can have several frames per regular window or just one. A user can scroll each frame independently.
Creating a frame:
<FRAMESET R0WS="50%,50%" C0LS="40%,60%">
<FRAME SRC="framconl.html " NAME="framel">
<FRAME SRC="framcon2.html" NAME="frame2"> </FRAMESET>
Accessing frame properties:
frames.1ength frames[0]name
62 hidden
frames[0].1ength frames[0].parent framesLO].self frames[0].wi ndow
Invoking frame methods:
frames[0].blur() frames[0].cl earTimeout(timer ID) frames[0].focus()
timerlD = frames[0].setTimeout("method(), 5000")
A hidden element is an input text field that doesn’t appear on-screen. Creating a hidden element:
<IN PUT TYPE="hi dden" NAME="markupPercent" VALUE=80>
Pretty straightforward, isn’t it? The preceding line of code defines a hidden element named markupPercent and stuffs it with the initial value of 80 so that subsequent calculations can add an 80 percent markup to any purchase. (I think you can guess why a programmer might want to hide a value like this!)
Previous << 1 .. 20 21 22 23 24 25 < 26 > 27 28 29 30 31 32 .. 72 >> Next