Oziam
01-19-2011, 03:21 AM
Hi,
I am new to javascript and cannot figure this out, it is probably very simple.
I am trying to select a new variable to write to a DIV,
I have the error messages set to variables like below;
the result is a pipe delimited string with the error and the field name,
e.g "error1|name" "error2|email" etc.... I have no problem retrieving
the result or splitting the string but I cannot seem to get the relevant
error message to display properly, it just displays the string "error1" or "error2" etc...
var error1 = "name error";
var error2 = "email error";
function doResult(result){
var n = result.split('|');
var err = n[0]; // this is the error id
document.getElementById(div_id).innerHTML = err;
return;
}
If I change the line;
document.getElementById(div_id).innerHTML = err;
to
document.getElementById(div_id).innerHTML = 'error1';
it shows the actual message as "name error" like it should????
Any help would be appreciated! Thanks!
I am new to javascript and cannot figure this out, it is probably very simple.
I am trying to select a new variable to write to a DIV,
I have the error messages set to variables like below;
the result is a pipe delimited string with the error and the field name,
e.g "error1|name" "error2|email" etc.... I have no problem retrieving
the result or splitting the string but I cannot seem to get the relevant
error message to display properly, it just displays the string "error1" or "error2" etc...
var error1 = "name error";
var error2 = "email error";
function doResult(result){
var n = result.split('|');
var err = n[0]; // this is the error id
document.getElementById(div_id).innerHTML = err;
return;
}
If I change the line;
document.getElementById(div_id).innerHTML = err;
to
document.getElementById(div_id).innerHTML = 'error1';
it shows the actual message as "name error" like it should????
Any help would be appreciated! Thanks!