JavaScript
SitePoint reference
Good reference for HTML, CSS, and JavaScript.
Programs in browsers
In this lesson, you will learn that:
- Some programs run inside browsers.
- Those programs are downloaded along with pages.
- Every major browser can run JavaScript programs.
- Programs are triggered by events.
- JavaScript is used for interface effects, validating form data, input widgets, and sending data to a server.
Finding JavaScript bugs
Learn:
- Syntax bugs happen when you type something the browser doesn’t understand, like
alrt().
- Use Firefox’s error console to track down syntax errors.
- Logic errors are when you tell the browser to do the wrong thing.
- Use
alert()statements to track program execution. Ifalertmessages are supposed to show up, but don’t, you know what code is not executing.
- Use
alert()statements to look at the values of variables.
Better client-side error display
Learn:
- How to report errors in a professional way.
- How page-wide, global error messages help the user.
- How JavaScript functions make error reporting easier to program.
Complete validation
This lessons shows a complete form validation example.
- It shows good error messages.
- Some error checking is on the server side. Some is on the client side.
- Bother server-side and client-side error messages are reported in the same way. That’s done by writing PHP code that calls JavaScript code.
Validation
You know how to grab data from text fields, and do things with them. But what if the user doesn’t type anything? Or says that his or her age is -15?
In this lesson, you learn how to:
- Check whether a field has a value.
- Check whether a number is OK.
Client-side validation
Learn:
- How to get form data into JavaScript variables.
- How to check that data for errors.
- How to report errors to the user.
The JavaScript connection
- JavaScript files contain file paths, just like HTML files. The paths can be broken when you use PHP to insert library files.
- You can fix the problem by creating a JavaScript variable in each file containing the path to the Web root. That variable is added to the JavaScript code in the library files.
- The JavaScript variable can have its value set by PHP.
Games
This lesson looks at adding games to your site. You’ll see how to create your own Mad Lib game. You can customize the game to match the content and the look and feel of your site.
Search
Search is one of the most important widgets. This lesson shows you how to add a simple search function to your site. You will learn:
- Why search makes your site more valuable.
- How to create a search form on your site.
- How to run Google searches from your site.