prolog2345
Programmer
Hi there, i am new to javascript and i was heaving a problem with the code below, i get a runtime exception saying 'id is null or not an object' ( i try to acces 'id' from the 'function formErr(arguments)' )
this does not make sence to me since everything seems quite straight forward. Perhaps when i pass the array to the function and than access it i must down cast or something.
Does anyone know the answer to this
thanks.
//---------------------------------------
function checkLoginCredentials()
{
checkName( document.getElementById('username') , document.getElementById('password')
)
}
function checkName(username, password)
{
if ( ( username.value ) && ( password.value ) )
return true;
var array = new Array(2);
if ( username.value )
array[0] = username;
if ( password.value )
array[1] =password;
// return formErr(username , password );
return formErr(array);
}
function formErr( arguments )
{
var message = "The following fields are empty:\n";
var entries = arguments;
for(i=0; i<entries.length; i++)
{
message += entries.id + "\n";
}
alert(message);
return false;
}
this does not make sence to me since everything seems quite straight forward. Perhaps when i pass the array to the function and than access it i must down cast or something.
Does anyone know the answer to this
thanks.
//---------------------------------------
function checkLoginCredentials()
{
checkName( document.getElementById('username') , document.getElementById('password')
)
}
function checkName(username, password)
{
if ( ( username.value ) && ( password.value ) )
return true;
var array = new Array(2);
if ( username.value )
array[0] = username;
if ( password.value )
array[1] =password;
// return formErr(username , password );
return formErr(array);
}
function formErr( arguments )
{
var message = "The following fields are empty:\n";
var entries = arguments;
for(i=0; i<entries.length; i++)
{
message += entries.id + "\n";
}
alert(message);
return false;
}