What am I doing wrong here? How do I declare an associative array?

Sharky Forums


Results 1 to 3 of 3

Thread: What am I doing wrong here? How do I declare an associative array?

  1. #1
    Hammerhead Shark Alphathree's Avatar
    Join Date
    Oct 2000
    Location
    Windsor, Ontario, Canada
    Posts
    1,842

    Post What am I doing wrong here? How do I declare an associative array?

    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.
    I miss Off Topic.

  2. #2
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077

    Post

    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).]

  3. #3
    Hammerhead Shark Alphathree's Avatar
    Join Date
    Oct 2000
    Location
    Windsor, Ontario, Canada
    Posts
    1,842

    Post

    Sorry I threw that message together in a hurry. Yes, Javascript

    Thanks, that should work.

    ------------------
    I miss Off Topic.
    I miss Off Topic.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •