I’m trying to pass a variable to a function to create an array via an onclick event. Everything works except for this line “arrSortBy = new Array(b);”. It works if I manually plug in the correct values (i.e. arrSortBy = new Array(“One”,”Two”,”Three”); ), but the values change from page to page so I need to pass a variable instead of having static code. Can anyone tell me what I’m doing wrong? Here’s my code.
Javascript
[CODE]
function cmdClearSortBy(a){
var b = a.replace(/,/g, “”,””);
b = “”” + b + “””;
arrSortBy = new Array(b);
var m;
var n;
for(i=0;i<arrSortBy.length;i++){
m = arrSortBy[i] + “ASC”;
n = arrSortBy[i] + “DESC”;
document.getElementById(m).src = “../Images/down_arrow_grey.gif”;
document.getElementById(n).src = “../Images/up_arrow_grey.gif”;
}
var x = document.forms.PURLHits;
x.txtSortBy.value = “”;
}
HTML
[CODE]
<input type=”button” name=”ClearSortBy” value=”Clear” onclick=”cmdClearSortBy(‘One,Two,Three’)” tabindex=”7″>