javascript classes - Online Tech Support
  Home
 

The JavaScript is used in web programming to extend HTML commands and give more flexibility and additional options to solve complicated web page solutions. JavaScript is part of HTML code, but it is not HTML. Read more about HTML on this link.

The first Online Tech Support example shows only a “pure” HTML source without any JavaScript objects.

<html>
  <body>
    <h2>My Web Page</h2>
    </body>
</html>

online tech support online computer help computer technician computer problems computer javascript tutorial javascript learn web design learn javascript courses online javascript online course javascript classes javascript tutorial javascript

You can try this JavaScript If example on this link.

The second JavaScript tutorial example is with the same HTML code above but with additional JavaScript output text that says “Hello JavaScript!” This is your first HTML page using JavaScript method and it writes on the screen. The JavaScript is defined between the script tags that give you an sign that this is not any more just HTML code. To write on screen we are using method write and it applies to object document. The “Hello JavaScript!” text contains both side the p-tags (paragraph) that do belong to HTML but would make the output text look better on a browser screen.

<html>
  <body>
    <h2>My Web Page</h2>

    <script type="text/javascript">
      document.write("<p>Hello JavaScript!</p>");
    </script>

  </body>
</html>

online tech support online computer help computer technician computer problems computer javascript tutorial javascript learn web design learn javascript courses online javascript online course javascript classes javascript tutorial javascript

You can try this JavaScript If example on this link.

Now take a look at our other example on the main screen to try out more JavaScript methods.



See Also:
Home

 

JavaScript If statement allows doing comparison and it does execute different type of decisions depending on the match. The JavaScript IF statement syntax is:

if (<your_condition>)
  {
     <execute this code if the condition is true>;
   }

The first example is done using condition “1”==”1″ and since this is always true the output text is showing “The IF statement is true“. We did include the HTML paragraph tags <p> and </p> so the text would look better on your web page.

<html>
  <body>
    <h2>My JavaScript If Statement</h2>

    <script type="text/javascript">
     if ("1"=="1") 
     {
      document.write("<p>The IF statement is true</p>");
      }
     </script>

    </body>
</html>

online tech support online computer help computer technician computer problems computer javascript classes javascript if javascript if else javascript else if javascript if else in javascript if in javascript javascript tutorial design learn web design javascript courses online javascript online course javascript classes javascript tutorial javascript

You can try this JavaScript If example on this link.

The ELSE syntax is almost the same as the IF with only one exception there is the else block added to the end.

if (<your_condition>)
  {
    <execute this code if the condition is true>;
   }
else
  {
    <otherwise execute this code>;
   }

This second example will show text of the else block and the reason is in the if condition there we have set “1”==”2″ and this condition is NOT true. Since the if condition is false the JavaScript will skip the firts part and continues with the else code.

<html>
  <body>
    <h2>My JavaScript If Statement</h2>

    <script type="text/javascript">
     if ("1"=="2") 
      {
        document.write("<p>The IF statement is true</p>");
       }
     else
       {
        document.write("<p>The ELSE statement</p>");
        }
     </script>

    </body>
</html>

online tech support online computer help computer technician computer problems computer javascript classes javascript if javascript if else javascript else if javascript if else in javascript if in javascript javascript tutorial design learn web design javascript courses online javascript online course javascript classes javascript tutorial javascript

You can try this JavaScript If Else example on this link.

The Third syntax has additional condition block ELSE IF and this used to declare more conditions to the IF statement. When the entire IF and ELSE IF conditions are not true then JavaScript will end up executing the ELSE statement.

if (<your_condition>)
  {
    <execute this code if the condition is true>;
   }
else if (<your_2nd_condition>)
  {
    <execute this code if your second condition is true>;
   }
else
  {
    <otherwise execute this code>;
   }

Now let’s see how works the ELSE IF statement and to do it we have set the first if condition to false and the else if condition is set to true. This example shows how JavaScript skips the first and the last else conditions. The reason is that JavaScript is looking for the first true condition and skips the next ones even if they are true.

<html>
  <body>
    <h2>My JavaScript If Statement</h2>

    <script type="text/javascript">
     if ("1"=="2") 
      {
        document.write("<p>The IF statement is true</p>");
       }
     else if ("2"=="2")
      {
       document.write("<p>The ELSE IF statement is true</p>");
       }
     else
       {
        document.write("<p>The ELSE statement</p>");
        }
     </script>

    </body>
</html>

online tech support online computer help computer technician computer problems computer javascript classes javascript if javascript if else javascript else if javascript if else in javascript if in javascript javascript tutorial design learn web design javascript courses online javascript online course javascript classes javascript tutorial javascript

You can try this JavaScript Else If example on this link.

We will try again two true else if conditions and as the next example shows only the first true condition will be executed and rest ignored.

<html>
  <body>
    <h2>My JavaScript If Statement</h2>

    <script type="text/javascript">
     if ("1"=="2") 
     {
      document.write("<p>The IF statement is true</p>");
      }
     else if ("2"=="2")
     {
      document.write("<p>The 1st ELSE IF statement is true</p>");
      }
     else if ("3"=="3")
     {
      document.write("<p>The 2nd ELSE IF statement is true</p>");
      }
     else
      {
      document.write("<p>The ELSE statement</p>");
       }
     </script>

    </body>
</html>

online tech support online computer help computer technician computer problems computer javascript classes javascript if javascript if else javascript else if javascript if else in javascript if in javascript javascript tutorial design learn web design javascript courses online javascript online course javascript classes javascript tutorial javascript

You can try this Second JavaScript Else If example on this link.



See Also:
Home

 

The JavaScript Substring method allows to extract or cut out a piece of text from the input string. The method has two input parameters “start position” and “end position“. The “start position” parameter is requited and if the “end position” is missing the method takes all way up to the end of string. The syntax of JavaScript Substring is following:

<string_variable>.substring(<start_position>,<end_position>);

On this first JavaScript example below we are declaring a string variable named my_text and we will assign to it value “JavaScript Online Course“. On the following line in the example will cut off the first 11 letter using the JavaScript Substring and the result becomes “Online Course“.

<html>
  <body>
    <h2>My JavaScript Substring Example 1</h2>

    <script type="text/javascript">

      var my_text = "JavaScript Online Course";
      document.write("<p>"+my_text.substring(11)+"</p>");

     </script>

    </body>
</html>

online tech support computer help computer technician computer problems javascript classes javascript substring javascript substring in javascript courses online javascript online course javascript

You can try this example on this link.

To set as well the end position use the position number in the main string as on the following example. It removes the “Course” word from the end leaving only word “Online“.

<html>
  <body>
    <h2>My JavaScript Substring Example 1</h2>

    <script type="text/javascript">

      var my_text = "JavaScript Online Course";
      document.write("<p>"+my_text.substring(11,17)+"</p>");

     </script>

    </body>
</html>

online tech support computer help computer technician computer problems javascript classes javascript substring javascript substring in javascript courses online javascript online course javascript

You can try this example on this link.



See Also:
Home

 

This tutorial is based on examples to be easier to follow. In JavaScript the Length method is used to get the amount of characters in text. JavaScript length does not have any input parameters and the method is applied to JavaScript variable. The syntax of JavaScript String Length is:

<string_variable>.length;

In this JavaScript Tutorial example we will declare string variable named my_text and we are assigning to it value “JavaScript Online Course“. The all string contains 24 letters and the JavaScript Length returns the same number, see the example below.

<html>
  <body>
    <h2>My JavaScript String Length Example</h2>

    <script type="text/javascript">

      var my_text = "JavaScript Online Course";
      document.write("<p>The length is "+my_text.length+"</p>");

     </script>

    </body>
</html>

online tech support computer help computer technician computer problems javascript classes javascript string length javascript length in javascript string length in javascript courses online javascript online course retirement planning retirement

You can try this example on this link.

See Also:
Home