JS-beginner
<Beginner JS><Function><Variable><Loop-If><OOP>
1/ General concepts
Class
It is a technique used to provide the criteria to define an object
The list of items used to describe something
Object
It is the result of a description based on a class
Method
An action that an object can perform
document.write("Jacques")
- document: Object
- write: method
- Jacques : Argument
Properties
It is the caracteristics used to describe an object. A property is created like a variable
Method and their arguments
It is a value that needs the method to work with to perform an action
protectRain(Reason)
Argument
An item or value that a function needs.
It is provided between parenthesis
Start and end
<script> </script>
or
<script language="Javascript"> </script>
Display string
document.write("Jacques")
2/ Forms
<form></form>
Refering to a form
document.CreditApplicationForm
2.1./ Text box
<input type="text">
Size
<...... size="40">
Value in a text box
<..... value="hello">
Name of the text box
<..... name="FName">
Large text area
<textarea cols="40"></textarea>
Password text area
<input type="password">
Events of a text box
OnFocus
OnKeyDown
OnKeyUp
OnKeyPress
OnChange
OnBlur
<.... OnChange....>
Check box
<input type="checkbox" checked="true">
Combo box
<select>
<option>S</option>
<option>M</option>
<option>L</option>
<option selected="true">XL</option>
</select>
List box
<select size="4">
<option>S</option>
<option>M</option>
<option>L</option>
<option>XL</option>
</select>
For multiple selection:
<select size="4" multiple>
2.2/ Table
<table>
<tr>
<td></td>
<td></td>
</tr>
</table>
2.3/ Button
<input type="button" OnClick....>
Submit Button
<input type="submit">
Reset Button
<input type="reset">
Radio Buttons
<input type="radio">
3/ Comments
// single line comment
/* multiple line
comment */
4/ Other
Message box
- with ok button only
alert("Yo man!");
- with ok/cancel buttons
confirm("You sure?");
Integer conversion
parse Int()
it converts what starts with digits to digits
216PLL - > 216
124 - > 124
He12 -> NaN (Not A Number error)
Decimal conversion
A value entered in a text box should be converted before using it in calculation
parsefloat(value);
Conversion to String
string(value);
Precision conversion(=rounding)
Fixed:
toFixed(number of digits);
ex: subTotal.toFixed(2);
Expression evaluation (is it valid)
eval(expression);
ex: eval(ord1*ord2);
Closing window
close()
The document class
document=it is the main area of the browser
document class=it is the content of the webpage
title=browser`s title bar. It is created in the head section.
document.write(document.title);
background color=you have to assign a hex format of the color.
document.bgcolor="#FF00FF";
Conditional operators
== Equality
document.write(15==32);//false
! Not
To make a variable temporarily unusable you can nullify its value
!TaxAmount
!= Different
15 != 33 //true
< , <= , > , >=
document.write(15>=32); //false
Comments
Post a Comment