[Javascript] Array-Indexing Problem

Tim Makins spindrift at oceanfree.net
Mon Sep 13 05:25:54 CDT 2004


Hi - please can you have a look at the script below. The first and second
Alerts work OK, but the third one fails. Why is that, and how can I correct
it ?

Tim in Ireland.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta content="text/html; charset=windows-1252" http-equiv=Content-Type>
<script language="javascript">
viewlist1 = {
colname: ["John","Frank","George"],
colwidth: [200,50,150]
}

viewlist2 = {
colname: ["Jane","Margaret","Sue"],
colwidth: [89,33,264]
}

viewlist3 = {
colname: ["Apple","Pear","Banana"],
colwidth: [12,4435,22]
}
</script>
</head>
<body>
<script language="javascript">
var index_num = 2;
var alias = 'viewlist'+ index_num;
alert(alias);
alert(viewlist2.colname[0]);
alert(alias.colname[0]);
</script>
</body>
</html>




More information about the Javascript mailing list