Main Content

Javascript examples (some PHP and MySQL too)

Archive - Originally posted on "The Horse's Mouth" - 2005-08-13 06:56:53 - Graham Ellis

If you're looking for some simple examples in Javascript (alert window, checking the value in a field, one select box that depends on another, checking window width and browser type), etc, I've just posted some short pieces of code that I wrote yesterday to our client side technology area. So often I find that good examples of Javascript are deeply tied up within beautifully-displaying HTML that's difficult to read if you're looking at it to ask "how do they do that"?

The example that generates a pulldown menu based on what you've selected in another pulldown menu (exactly the sort of thing you'll want to do with - for example - make and model or country and town selections) also includes a PHP form with the Javascript to show how they work together, and use of data held in an SQL database too. Run the example at our demo area

"But I thought you didn't run Javascript courses, Graham". Correct - I don't have the notes and I don't have the in-depth knowledge to feel confident in running a whole course over several days on the subject. BUT ... it's an important adjunct in HTML, in contract work, in our own web site, and also as it relates to web sites that are server side using PHP, Perl, Python or Tcl. So I can and will cover elements of Javascript as needed within other courses.




Updated, 6th September 2009. Here are direct links to the examples that I am talking about ...

dynamic.html   Dynamic Image (Using Javascript)
eight.php   Disabling a form input until another element has been completed
fifth.html   Providing different links depending on which browser
first.html   Simple Javascript variables, and an alert box
fourth.html   reporting platform information via Javascript
isflash.html   Sensing whether Flash is available on a browser
jskl.html   Javascript event handling on a form (textarea)
nine.php   Javascript, PHP and MySQL used together - training example
second.html   Conditional in Javascript - wording based on browser
seven.php   Changing one Select menu based on another selection
six.php   Validating user entries at the browser
smonth.php   Disabling a form input until another element has been completed
terry2.html   Roll over an image to change another image
third.html   Checking plugin availability