If I have the following functions, is there a way to alter showData()
to get at the value of the array without resorting to an eval?
<html>
<head>
<title>Test</title>
<script type="text/javascript" language="javascript">
// <![CDATA[
var gRaces = new Array();
gRaces[ "elf" ]= { str:8, dex:10, con:6, 'int':8, wis:8,
cha:8 };
gRaces[ "half-elf" ]= { str:8, dex:10, con:8, 'int':8, wis:8,
cha:8 };
gRaces[ "half-orc" ]= { str:10, dex:8, con:8, 'int':6, wis:8,
cha:6 };
function showData(race, ab) {
alert( eval( 'gRaces[race].' + ab ) );
}
// ]]>
</script>
</head>
<body onload="showData('half-orc', 'int')">
</body>
</html>
--
cp