Hi all.
I am using the script below which only work when a named field within my FORM has focus. What I want to do is execute the script when the page loads. Can this be done.
<script type=”text/javascript”>
var ajax = new sack();
var currentClientID=false;
function getClientData()
{
var clientId = document.getElementById(‘clientID’).value.replace(/[^a-zA-Z]/i,”);
if(clientId.length==3 && clientId!=currentClientID){
currentClientID = clientId
ajax.requestFile = ‘getClient.php?getClientId=’+clientId; // Specifying which file to get
ajax.onCompletion = showClientData; // Specify function that will be executed after file has been found
ajax.runAJAX(); // Execute AJAX function
}
}
function showClientData()
{
var formObj = document.forms[‘clientForm’];
eval(ajax.response);
}
function initFormEvents()
{
document.getElementById(‘clientID’).onfocus = getClientData;
document.getElementById(‘clientID’).focus();
}
window.onload = initFormEvents;
</script>