php-mysql tutorial

Designed By NISHANT GUPTA

  • Home
  • PHP
  • HTML
  • CSS
  • JavaScript
  • JQuery
  • Contact-us
  • Learn HTML

    • Introduction of HTML
    • Image Handling in HTML
    • List Handling in HTML
    • Font Handling in HTML
    • Table Handling in HTML
    • Form Handling in HTML
  • Learn CSS

    • Introduction of CSS
    • Styling Background in CSS
    • Styling Text in CSS
    • Styling Font in CSS
    • Styling Link in CSS
    • Styling List in CSS
    • Styling Table in CSS
    • Styling Div in CSS
    • Styling Span in CSS
    • Positioning in CSS
    • Display in CSS
  • Learn JavaScript

    • Introduction of JavaScript
    • Data Type in JavaScript
    • Variable in JavaScript
    • Oprator in JavaScript
    • Cond. Statement in JS
    • Loop in JavaScript
    • Array in JavaScript
    • Function in JavaScript
    • Date in JavaScript
    • String in JavaScript
    • DOM in JavaScript
    • Event Handling in JavaScript
    • Form Handling in JavaScript
  • Learn PHP-MYSQL

    • Introduction of PHP
    • Decision Control in PHP
    • Loop in PHP
    • Array in PHP
    • Function in PHP
    • Form Handling in PHP
    • File Inclusion in PHP

Conditional Statement in JavaScript

Conditional Statements
JavaScript language supports following type of conditional statements:
  1. if
  2. if else
  3. if else if else
  4. Nested if
  5. Ternary Operator
  6. switch

If Statement

if statement is used to execute some code only if a specified condition is true.

Syntax

If(<test cond>)

{

  //statement

}

If  else  Statement

 if....else statement is used to execute some code if a condition is true and another code if the condition is not true.

Syntax

If(<test cond>)

{

  //statement

}

else

{

  //statement

}

If  else if else  Statement

The if....else if...else statement is used to select one of several blocks of code to be executed.

Syntax

If(<test condition>)

{

  //statement

}

else if(<test condition>)

{

  //statement

}

else

{

  //statement

}

Nested If Statement

Syntax

If(<test condition>)

{

  if(<test condition>)

  {

    // statement

  }

}

Ternary Operator

The ternary operator in javascript is a shorthand of if-else construct and has the following syntax:

Syntax

<varname>=(<test cond>)?<true>:<false>;

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
}

 

Advertisements

 

©  2014 All Rights Reserved  •  Design by >Nishant Gupta.

Privacy Policy • Terms of Use