In the following script, I want to select from the various ‘indxA’ … ‘indxJ’ arrays.
But the way I have coded it, it thinks ‘myindx’ is a string and is passing back the characters of the string instead of the elements of the selected array.
Is there a way to code this differently so that it works the way I want?
[code=php]
<html>
<head>
<title>Indirect Loop</title>
<script type=”text/javascript”>
var indxA = new Array(‘A’,”Abner”,”Allison”,”Avery”);
var indxB = new Array(‘B’,”Barney”,”Beenie”,”Beers”,”Boop”);
var indxC = new Array(‘C’,”Cary”,”Connelly”,”Conroy”,”Crestview”,”Custer”);
var indxD = new Array(‘D’,’Duck’);
var indxE = new Array(‘E’,’Elliot’,’Emory’,’Excellent’);
var indxF = new Array(‘F’,’Fudd’);
var indxG = new Array(‘G’);
var indxH = new Array(‘H’);
var indxI = new Array(‘I’);
var indxJ = new Array(‘J’);
function Act(info) {
var strmsg = ”;
myindx = ‘indx’+info;
for(var i=0; i<myindx.length; i++) {
strmsg+=”<a href=’#null’>”+myindx[i]+'</a> ‘; // strmsg+=”<br>”; // for vertical display
}
document.getElementById(“divdis”).innerHTML=strmsg;
}
AlphaIndex = {
Chrs : new Array(‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’),
// ,’K’,’L’,’M’,’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’),
InitH : function() {
document.writeln(‘<table border=”0″><tr>’);
for (az=0; az<this.Chrs.length; az++) {
document.writeln(‘<td><button onClick=”Act(”+this.Chrs[az]+”)”>’+this.Chrs[az]+'</button>’);
}
document.writeln(‘</tr></table>’);
}
}
</script>
</head>
<body>
<script type=”text/javascript”> AlphaIndex.InitH(); </script>
<br>
<div id=divdis ></div>
</body>
</html>