I have the following function, which is called when a link is clicked on the page (there will be a list of names, each of which calls this function). I thought I wrote it so that if the second one is clicked it will add to the array, but it keeps replacing it. What am I doing wrong?
guestlist=null;
function QueueUser(uid,thename) {
document.getElementById('GuestQueue').style.visibility = "visible";
if (!guestlist) {
var guestlist = new Array();
}
var arrLen = guestlist.length;
//alert(arrLen);
var startnum=0;
if (arrLen != 0) {
startnum=arrLen+1;
}
guestlist[startnum]=[uid,thename];
//alert(guestlist[0]);
var vGuestQueue="<table width=100% cellpadding=0 cellspacing=0>";
for(i = 0; i < guestlist.length;i++){
//alert("hello");
vGuestQueue= vGuestQueue + "<tr><td>" + guestlist[1] + "</td><td><a href='javascript:void(0);' onClick='rmvGuest(" + guestlist[1] + ");'>remove</a></tr>";
}
vGuestQueue=vGuestQueue + "</table>";
document.getElementById("GuestQueueList").innerHTML =vGuestQueue;
}
guestlist=null;
function QueueUser(uid,thename) {
document.getElementById('GuestQueue').style.visibility = "visible";
if (!guestlist) {
var guestlist = new Array();
}
var arrLen = guestlist.length;
//alert(arrLen);
var startnum=0;
if (arrLen != 0) {
startnum=arrLen+1;
}
guestlist[startnum]=[uid,thename];
//alert(guestlist[0]);
var vGuestQueue="<table width=100% cellpadding=0 cellspacing=0>";
for(i = 0; i < guestlist.length;i++){
//alert("hello");
vGuestQueue= vGuestQueue + "<tr><td>" + guestlist[1] + "</td><td><a href='javascript:void(0);' onClick='rmvGuest(" + guestlist[1] + ");'>remove</a></tr>";
}
vGuestQueue=vGuestQueue + "</table>";
document.getElementById("GuestQueueList").innerHTML =vGuestQueue;
}