Entries from May 2008
To set the focus of a HTML text box include this short piece of code in the <head> section
<script>function setfoc() { document.f1.KeyWords.focus(); }
In the example above f1 is the name of the form and KeyWords is the name of the input textbox
In the body section:
<form name=”f1″ action=”youraction” method=”POST”>
<input type=”text” name=”KeyWords” size=”40″ value=”default text”>
</form>
<script language=”JavaScript”>setfoc();</script>
[...]
[Read more →]
Tags: Code
It is often useful to check that a given domain name or host is valid, this can be achieved using the checkdnserr() command, as in the following example:
$hostname = “www.domain.com.”;
$dnstype = “MX”;
$bValid = checkdnserr($hostname,$dnstype);
If using a DNS name then ensure the domain ends with the root domain qualifier (the “.”)
If the $dnstype is omitted or [...]
[Read more →]
Tags: Tip
Quick routine to mix up the items in an array
public Object[] MixUpArray(Object inarray[])
{
// get the size of the array
int iSize = inarray.length;
// create an array the same size as the input array
Object outarray[] = new Object[iSize];
// Convert the array to a Vector
Vector<Object> temparray = new Vector<Object>();
// Copy the [...]
[Read more →]
Tags: Code
This short routine shows how to ensure a selected item in a list is within bounds. If the list is empty the getSelectedIndex will return -1. The index starts at zero whilst size() will start at 1.
// perform bounds checking
int iIndex = myList.getSelectedIndex();
int iCount = myList.size();
// debugging information
System.out.println(”Index: ” + iIndex + ” Size: ” [...]
[Read more →]
Tags: Code