PDA

View Full Version : Simple array question?



lindm
02-24-2008, 02:24 PM
Probably a simple solution but here is my problem:

My script


function princ(field,text)
{
var text=new Array();
text[0]="test1";
text[1]="test2";
text[2]="test3";



var e = document.getElementById(field);

e.value=text[text];
}


Is called with


princ(PRINCint,1)

Get en "undefined error". I must try to access the array wrong...but how?

lindm
02-24-2008, 04:27 PM
Solved.

CHanged

function princ(field,text)

to

function princ(field,no)