We’ve already covered ‘creating a random image with JavaScript’ but the best way to produce a random image on each page load is to use PHP. Using PHP, you are not relying on the browser supporting JavaScript at all and everyone will see the random images.

OK, to start, we’ll create a function called randomSelect(). This will take two parameters; the directory to scan for images and an array of the allowed file extensions to use.

Continue reading »

 

To make it easier for your visitors to visually separate similar elements in your web page (such as table rows, paragraphs, list items etc), you can give alternate elements a different background colour. You can achieve this using a server-side script but here’s a really simple way to do this using JavaScript.

Continue reading »

 

If you have required fields in a form, a nice visual clue for the user is to have a message ‘pop up’ if the field hasn’t been filled in. A simple example of what I mean can be seen here.

Continue reading »

 

Although best practice dictates that you shouldn’t force a new browser window on a user, sometimes (perhaps for a PDF file) you really want to. If you’re using a transitional doctype, this isn’t a problem. You’d simply use the ‘target’ attribute and set it to ‘_blank’.

Continue reading »

 

In an ideal world, creating a cross-browser dropdown menu would be straight forward. Unfortunately, the world of browsers is far from ideal (as long as Internet Explorer 6 still exists!). For other browsers, the following code works fine: Continue reading »

 

Just a quick heads up to let you know that you can now download all of the source code for the PHP Quiz. This might make it easier for you to get up and running without trying to follow all of the series. I’ve also included the small amount of JavaScript too.

You can download it here. I’ll also put a download link at the top of each post in the series.

Cheers,
ElanMan

© 2012 ElanManSuffusion theme by Sayontan Sinha

Page optimized by WP Minify WordPress Plugin