LiveZilla Live Help

Opal Creations Blog | A bit about what we do and what we know!

CAT | Free Scripts and Code

This JavaScript function provides a simple script to generate a random HEX colour code that can be used on any DOM element. A simple call to the function “genHEX()” will return a 6 character string that changes everytime. This is useful if you want an element to be a different colour on each page load.

The Code

Below is the code, documentation is in the form of comments in the code.

function genHex(){
    // Make a new array with all available HEX options.
    var colours = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
    // Make variable to hold 6 character HEX array
    digit = new Array(5);
    for (i=0;i<6;i++){
        // Loop through 6 times, randomising the letter added to the array
        colour = colour+digit[i];
    // Returns like "a10bc5". It is likely that you may need to add a "#".
    return colour;

· · ·

This is a short guide for developers explaining how to access a visitor/users location based on their IP address. It works almost perfect in the US, and very well in the UK. Imagine being able to automatically identify where a user came from on your website, or even using this data to auto fill in a users address when they sign up to something on your website! Luckily this facility does not return house numbers (Yet). What this tutorial will do is at least provide an idea of a visitor’s exact city (in most cases). You also get the visitor’s approximated latitude and longitude, as well as his or her’s state/county, country, and country code. With my computer it got all but the county right, it thought my area in Swindon was Berkshire! The long/lat was about 400m out from my exact location. Thats quite good.

· · ·

So by now I’m sure you have been searching a long time to find a script or some code to help you build a SIMPLE php calendar script which displays the whole year to a page. Well hopefully this post will help you out. This script will help you build a yearly linear calendar, we needed this to view all our our clients renewal dates in a clear manner. My example code is is self contained in one file (you can split into modular files if you wish). There is no javascript needed, it is all in the PHP and HTML/CSS. Requires PHP4+

This code can easily be modded for database integration (which is what we are to use it for). We will try to help if anyone has any issues. At the moment you can pass in a YEAR parameter (either GET OR POST) and it will render that year… for example:

This is only the skin and bones of designing the PHP yearly calendar so please style it and add any relevant javascript/database connections as required.


· · ·

Theme Design by