Aug 12
style="[a-zA-Z0-9_;:%# -]+"

Jul 27
	$$('form.validate').addEvent('submit',function (e){

		var no_errors = true;
		$$('.required').each(function(input_el){
			if(!$(input_el).get('value'))
			{	input_el.addClass('error');
				no_errors = false;
			}
		});
		if(!no_errors)
			alert('Please fill all required fields');
		return no_errors;
	});

Jul 26

window.addEvent('domready',function(){
	$$('input[name=Enquiry_type]').addEvent('change',function()
	{	var Enquiry_Categories = [['option 1','option 2','option 3'],['option 4','option 5','option 6'],['option 7','option 8','option 9']];

		$('Enquiry_Sub_Category').empty();

		for(i=0; i<Enquiry_Categories[$(this).get('value')].length; i++)
		{	var option = Enquiry_Categories[$(this).get('value')][i];
			$('Enquiry_Sub_Category').grab(new Element('option',{value: option, html: option}));
		}
	});
});
<!-- when this is selected-->
<select name="Enquiry_type">
<option value="0">select this for options 1,2,3</option>
<option value="1">select this for options 4,5,6</option>
<option value="2">select this for options 7,8,9</option>
</select>

<!--this will get populated-->
<select name="Enquiry_Sub_Category">
</select>
'option 1','option 1',

Jul 23
$(body).toggleClass('enlarge'); //enlarge text link onclick
body p{
   font-size:12px;
}

body,enlarge p{
   font-size:16px;
}

Now you dont have to reload css files and have all the css in one file too.

Feb 04
Get errors like this?

Warning: dl(): Unable to load dynamic library 'libwebpayclient.so' - libssl.so.4: cannot open shared object file:
Not sure which package to install? Run the code below to find out!
 sudo apt-get install apt-file
 sudo apt-file update
 apt-file search libssl.so

Sep 04

I saw this method used in an old c cook book. Can’t remeber what it’s called, cascading switch anyone??


switch($section)
 {
 case 'year':
 if(empty($select))
 $select = ' * ';
 if(!empty($year))
 $where .= "    AND        `Year Range`    LIKE '%$year%' ";

 case 'submodel':
 if(empty($select))
 $select = ' TRIM(`Year Range`)';
 if(!empty($submodel))
 $where .= "    AND        `Model ID`         LIKE '%$submodel%' ";

 case 'engine':
 if(empty($select))
 $select = ' TRIM(`Model ID`) ';
 if(!empty($engine))
 $where .= "    AND        `Engine Size`     LIKE '%$engine%' ";

 case 'model':
 if(empty($select))
 $select = ' TRIM(`Engine Size`) ';
 if(!empty($model))
 $where .= "    AND     `Model Name`    LIKE '%$model%' ";

 case 'make':
 if(empty($select))
 $select = ' TRIM(`Model Name`) ';
 if(!empty($make))
 $where .= "    AND     `Make`             LIKE '%$make%' ";
 }

Sep 04

This is a simple script to go though a files inside a folder recursively and append the folder name to the file name.

The script is written for a windows system, just replace the \\ to / for unix.


function getDirectory( $path = '.', $level = 0 )
{    $dir_separator = '__';
 $ignore = array( 'cgi-bin', '.', '..','default.asp','index.php','PUT SELF IN THERE' );
 // Directories to ignore when listing output. Many hosts
 // will deny PHP access to the cgi-bin.

 $dh = @opendir( $path );
 // Open the directory to the handle $dh

 while( false !== ( $file = readdir( $dh ) ) ){
 // Loop through the directory

 if( !in_array( $file, $ignore ) && !strstr($file, $dir_separator))
 {    // Check that this file is not to be ignored
 //AND ALSO CHECK IF WE HAVENT ALRADY DONE THIS

 $spaces = str_repeat( '&nbsp;', ( $level * 4 ) );
 // Just to add spacing to the list, to better
 // show the directory tree.

 if( is_dir( "$path\\$file" ) )
 {    // Its a directory, so we need to keep reading down...

 //echo "<strong>$spaces $file</strong><br />";
 getDirectory( "$path\\$file", ($level+1) );
 // Re-call this same function but on a new directory.
 // this is what makes function recursive.
 } else {
 $rooot_path = 'C:\\xampp\\htdocs\\Documents';
 $old_filename = $rooot_path.substr("$path\\$file",1);
 $new_filename = substr($path,2);
 $new_filename = $rooot_path.substr('.\\'.$new_filename.'\\'.str_replace('\\',$separator,$new_filename).$separator.$file,1);
 echo "$old_filename -> $new_filename <br />";
 rename($old_filename,$new_filename);
 }
 }

 }
 closedir( $dh );
 // Close the directory handle
}

//run the function
getDirectory( "." );

Aug 24
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://cultivatewebdesign.com.au%{REQUEST_URI}

Aug 04
Cultivate Firefox persona

Cultivate Firefox persona

Check out the:

Firefox 3 Persona by Cultivate web design Melbourne

They are easy to create and offers great viral marketing value for your business.

Aug 04

While iframes are not good to use normaly, I use it to mix different server side languages. (eg: pulling through perl/ASP scripts to display on a php page). Please only use this for non indexed (admin/managemt/report) pages because iframes are no good for SEO.

Javascript for the parent page,

//this uses mootools. This code should be placed inside domready or load event of the window
$('my-iframe').addEvent('load',function()
{	innerDoc = ($('my-iframe').contentDocument) ? $('my-iframe').contentDocument : $('my-iframe').contentWindow.document;
	objToResize = ($('my-iframe').style) ? $('my-iframe').style : $('my-iframe');
	objToResize.height = (innerDoc.body.scrollHeight + 50) + 'px';
	objToResize.width = (innerDoc.body.scrollWidth + 20) + 'px';
	window.scrollTo(0, 0);//optional code to scroll the parent window back to top
});

And the iframe should look like this,

<iframe id="my-iframe" src="my_page_to_iframe.php" frameborder="0" scrolling="auto" ></iframe>

Thats it! If the sites are on two domains, take a look at this post to get around that.