Click to See Complete Forum and Search --> : What am I doing wrong here? How do I declare an associative array?


Alphathree
10-01-2001, 03:36 PM
var tips = new Array();
tips("January") = "Toxic Substances";
tips("February") = "Repetitive Strain Injury (RSI)";
tips("March") = "EMF Exposure";
tips("April") = "WHMIS";
tips("May") = "Pesticides";
tips("June") = "Workplace Harassment";
tips("July") = "Heat Stress";
tips("August") = "Smog";
tips("September") = "Shift Work";
tips("October") = "Ergonomics";
tips("November") = "Lock Out";
tips("December") = "Indoor Air Quality";


------------------
I miss Off Topic. :(

Grizzly
10-01-2001, 07:11 PM
In what language? JavaScript?


In JavaScript you do basically that, but replace all of your "(" and ")" with "[" and "]".

Like this:

var tips = new Array();
tips["January"] = "Toxic Substances";
tips["February"] = "Repetitive Strain Injury (RSI)";
tips["March"] = "EMF Exposure";
tips["April"] = "WHMIS";
tips["May"] = "Pesticides";
tips["June"] = "Workplace Harassment";
tips["July"] = "Heat Stress";
tips["August"] = "Smog";
tips["September"] = "Shift Work";
tips["October"] = "Ergonomics";
tips["November"] = "Lock Out";
tips["December"] = "Indoor Air Quality";

[This message has been edited by Grizzly (edited October 01, 2001).]

Alphathree
10-02-2001, 07:05 AM
Sorry I threw that message together in a hurry. Yes, Javascript http://www.sharkyforums.com/ubb/smile.gif

Thanks, that should work.

------------------
I miss Off Topic. :(