Javascript To String: Formatting Data Using toString in Javascript

You can use toString() in javascript to format arrays and numbers as strings. The following HTML page contains embedded javascript that does exactly that. <html> <head> <title>Test Page</title> </style> <script language=”javascript”> function run() { var num1 = 72.6; var fruits … Continue reading

Posted in Javascript | Tagged , |

Javascript HTML: Generating HTML and Embedding Javascript in HTML

This page covers the following topics: Embedding Javascript in HTML Embedding Javascript Directly in HTML: A Button Click Example Generating HTML With Javascript Embedding HTML in Javascript Embedding Javascript in HTML The way that’s most often used to store javascript … Continue reading

Posted in Javascript | Tagged , , |

Javascript For: Loops in Javascript

The most common type of loop in javascript is probably the for loop. There are two common ways of using for. The first way involves using a variable to count however many loop iterations you want to make. Note that … Continue reading

Posted in Javascript | Tagged , , |

Javascript In: Using the ‘In’ Operator to Iterate Through Arrays and Objects

You can use the in operator in javascript to iterate through arrays or objects. This makes it particularly handy for viewing the properties and methods of an object, among other things. It’s also useful for checking if particular hash keys … Continue reading

Posted in Javascript | Tagged , |

PHP JSON: An Example Javascript JSON Client With PHP Server

While JSON has many uses, probably the most common use is to pass data structures to Javascript. JSON is simply a standard format for data structures. In this example we’ll use a PHP page as a JSON server; we’ll use … Continue reading

Posted in PHP | Tagged , , , , , |

Javascript Function: Defining, Calling and Using Functions in Javascript

A Basic Function A Function With Parameters Calling a Function Using Onclick Calling a Function When the Page is Loaded Anonymous Functions and Function Pointers in Javascript A Basic Function You can create a function in javascript like this: function … Continue reading

Posted in Javascript | Tagged , , |

Javascript Array: How To Use Arrays in Javascript

Creating and Initializing Arrays In Javascript Multidimensional Arrays in Javascript Iterating Through Arrays in Javascript Javascript Array Sort: Sorting Arrays in Javascript Pop and Shift: Removing Elements From Arrays in Javascript Javascript Slice: Selecting Part of an Array Javascript Array … Continue reading

Posted in Javascript | Tagged , , |