Search Blog Posts

‘Scripts’

Focusing a specific form field on page load

Thursday, September 25th, 2008

If you require a form field to be set as the focus when the page loads, we can use the onload function to make this possible.

All you need to do is use the code below and replace the FormName and FormField with your elements names and all should work fine.

<body onload="document.FormName.FormField.focus()">

PHP capitalising the first letters of each word in a sentance

Friday, June 27th, 2008

I recently wanted a contact form to convert a form element, in this case someones name to uppercase. For example ‘tom peters’ decided to enter his name without any capitals. The desired result would ideally be ‘Tom Peters’.

Using PHP we can convert the form field variable by doing the following:

$personsname= "tom peters";
$PersonsName = ucwords($personsname);

echo "<p>The old string - $personsname <br />";
echo "The new string - $PersonsName </p>";

There are a few more examples that you could experiment with for example:
strtolower(); will convert a string to lowercase.
strtoupper(); will convert a string to uppercase.

Active X Script

Friday, September 28th, 2007

The following code removed the border from flash files in i.e etc

Place this in the head tags:
<script type="text/javascript" src="scripts/swfobject.js" mce_src="scripts/swfobject.js"></script>
Place this in the body:

<p id="flash" class="wrap"><!-- this is where the flash will be placed put an image here for users who dont have flash --></p>
<script type="text/javascript"> var so = new SWFObject("flash/filename.swf", "nameofflash", "690", "220", "8", "#dbd9ca", "high"); so.write("flash"); </script>

Attached is the swf object script. Put this in a folder named scripts.

swfobject

© Copyright 2003-2008 Minimalistic Designs | Terms | Links | Sitemap
Website Design Liskeard - www.minimalistics.co.uk