Skip to main content

Home/ Groups/ Learning Library
Sunny Jackson

JavaScript If...Else Statements - 0 views

  • Conditional statements are used to perform different actions based on different conditions.
  • if statement - use this statement to execute some code only if a specified condition is true
  • if...else statement - use this statement to execute some code if the condition is true and another code if the condition is false
  • ...8 more annotations...
  • if...else if....else statement - use this statement to select one of many blocks of code to be executed
  • switch statement - use this statement to select one of many blocks of code to be executed
  • Use the if statement to execute some code only if a specified condition is true. Syntax if (condition)   {   code to be executed if condition is true   }
  • Note that if is written in lowercase letters. Using uppercase letters (IF) will generate a JavaScript error!
  • Notice that there is no ..else.. in this syntax. You tell the browser to execute some code only if the specified condition is true.
  • If...else Statement Use the if....else statement to execute some code if a condition is true and another code if the condition is not true.
  • Syntax if (condition)   {   code to be executed if condition is true   } else   {   code to be executed if condition is not true   }
  • If...else if...else Statement Use the if....else if...else statement to select one of several blocks of code to be executed. Syntax if (condition1)   {   code to be executed if condition1 is true   } else if (condition2)   {   code to be executed if condition2 is true   } else   {   code to be executed if condition1 and condition2 are not true   }
Sunny Jackson

JavaScript Switch Statement - 0 views

  • The JavaScript Switch Statement Use the switch statement to select one of many blocks of code to be executed. Syntax switch(n) { case 1:   execute code block 1   break; case 2:   execute code block 2   break; default:   code to be executed if n is different from case 1 and 2 }
  • Use break to prevent the code from running into the next case automatically.
Sunny Jackson

JavaScript Introduction - 0 views

  • A scripting language is a lightweight programming language
  • Java and JavaScript are two completely different languages in both concept and design!
Sunny Jackson

Virginia Apgar - 0 views

Sunny Jackson

Ruth Benedict - 0 views

Sunny Jackson

Franz Kafka - 0 views

Sunny Jackson

John Keats - 0 views

Sunny Jackson

Bella Abzug - 0 views

Sunny Jackson

Jane Addams - 0 views

Sunny Jackson

Eleanor Baum - 0 views

Sunny Jackson

JavaScript Popup Boxes - 0 views

  • JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box.
  • Alert Box An alert box is often used if you want to make sure information comes through to the user. When an alert box pops up, the user will have to click "OK" to proceed.
  • Syntax alert("sometext");
  • ...5 more annotations...
  • <script type="text/javascript"> function show_alert() { alert("I am an alert box!"); } </script>
  • Confirm Box A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false. Syntax confirm("sometext");
  • <script type="text/javascript"> function show_confirm() { var r=confirm("Press a button"); if (r==true)   {   alert("You pressed OK!");   } else   {   alert("You pressed Cancel!");   } } </script>
  • Prompt Box A prompt box is often used if you want the user to input a value before entering a page. When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value. If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null. Syntax prompt("sometext","defaultvalue");
  • <script type="text/javascript"> function show_prompt() { var name=prompt("Please enter your name","Harry Potter"); if (name!=null && name!="")   {   document.write("Hello " + name + "! How are you today?");   } } </script>
Sunny Jackson

JavaScript Functions - 0 views

  • A function will be executed by an event or by a call to the function.
  • To keep the browser from executing a script when the page loads, you can put your script into a function.
  • A function contains code that will be executed by an event or by a call to the function.
  • ...13 more annotations...
  • You may call a function from anywhere within a page (or even from other pages if the function is embedded in an external .js file).
  • Functions can be defined both in the <head> and in the <body> section of a document. However, to assure that a function is read/loaded by the browser before it is called, it could be wise to put functions in the <head> section.
  • How to Define a Function Syntax function functionname(var1,var2,...,varX) { some code }
  • The { and the } defines the start and end of the function.
  • The parameters var1, var2, etc. are variables or values passed into the function.
  • A function with no parameters must include the parentheses () after the function name.
  • The word function must be written in lowercase letters, otherwise a JavaScript error occurs!
  • Also note that you must call a function with the exact same capitals as in the function name.
  • The return Statement The return statement is used to specify the value that is returned from the function. So, functions that are going to return a value must use the return statement.
  • <script type="text/javascript"> function product(a,b) { return a*b; } </script>
  • If you declare a variable, using "var", within a function, the variable can only be accessed within that function. When you exit the function, the variable is destroyed. These variables are called local variables.
  • You can have local variables with the same name in different functions, because each is recognized only by the function in which it is declared.
  • If you declare a variable outside a function, all the functions on your page can access it. The lifetime of these variables starts when they are declared, and ends when the page is closed.
Sunny Jackson

W3Schools Online Web Tutorials - 0 views

Sunny Jackson

W3Schools' Certifications - 0 views

  • Online Certification Program
  • Study at no cost
  • Study when it is convenient
  • ...11 more annotations...
  • Study from your own computer
  • HTML Developer Certificate
  • CSS Developer Certificate
  • JavaScript Developer Certificate
  • jQuery Developer Certificate
  • XML Developer Certificate
  • ASP Developer Certificate
  • PHP Developer Certificate
  • Documentation of your skills enables you to move upwards
  • Getting a certificate proves your commitment to upgrade your skills, gives you the credibility needed for more responsibilities, larger projects, and a higher salary.
  • documented knowledge is often the key factor when hiring new personnel
Sunny Jackson

HTML Colors - 0 views

« First ‹ Previous 101 - 120 Next › Last »
Showing 20 items per page