Question on JavaScript Objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chad Lupkes

    Question on JavaScript Objects

    Hi everyone,

    I'm just starting in Javascript, and I'm trying to get this to work.
    I have three image maps that I am trying to allow people to choose
    from, and I'd rather not have three separate pages to flip through.
    I'm thinking that if I create an array, I can dynamically assign
    values to the title of the map, the img file source, and the name of
    the image map to use. Here is my array:

    <script language="JavaS cript" type="text/javascript">
    function map_onlick()
    {
    var whichMap = new Array();

    whichMap[0] = new Array();
    whichMap[0][0] = "World Map";
    whichMap[0][1] = "/atctestsite/affiliates/gifs/world15.gif";
    whichMap[0][2] = "worldmap";

    whichMap[1] = new Array();
    whichMap[1][0] = "North America";
    whichMap[1][1] = "/atctestsite/affiliates/gifs/northamerica.gi f";
    whichMap[1][2] = "northameri ca";

    whichMap[2] = new Array();
    whichMap[2][0] = "United States";
    whichMap[2][1] = "/atctestsite/affiliates/gifs/usa_color.gif";
    whichMap[2][2] = "unitedstat es";
    }
    </script>

    Now, with this defined, I should be able to choose which one to use,
    and change the objects in the body of the document to the resulting
    values. The problem is, I'm having trouble finding a good description
    of how to define objects like Headers and imagemaps. I would like to
    be able to use the basic document objects, but if I create the header
    like this:

    <h1 name="title1">W orld Map</h1>

    how do I change that to either "North America" or "United States" if
    the correct link is chosen? I can see that this will be a function
    call, probably called when the onclick() event is seen, but I'm
    getting lost how to go any further.

    Anyone have any ideas?

    Chad Lupkes
    chadlupkes@eart hlink.net
  • steve stevo

    #2
    Re: Question on JavaScript Objects

    ok i sort of see what your doing - you want to dynamically change the name
    of the h1 tag .

    function changeTag(x){ // x will be your first element number in your multi
    dimentional array
    title1.innerTEX T = whichMap[x][0]
    }

    hope this helps

    Simon Christie




    "Chad Lupkes" <chadlupkes@yah oo.com> wrote in message
    news:8b0a004d.0 309211648.67fa0 0c@posting.goog le.com...[color=blue]
    > Hi everyone,
    >
    > I'm just starting in Javascript, and I'm trying to get this to work.
    > I have three image maps that I am trying to allow people to choose
    > from, and I'd rather not have three separate pages to flip through.
    > I'm thinking that if I create an array, I can dynamically assign
    > values to the title of the map, the img file source, and the name of
    > the image map to use. Here is my array:
    >
    > <script language="JavaS cript" type="text/javascript">
    > function map_onlick()
    > {
    > var whichMap = new Array();
    >
    > whichMap[0] = new Array();
    > whichMap[0][0] = "World Map";
    > whichMap[0][1] = "/atctestsite/affiliates/gifs/world15.gif";
    > whichMap[0][2] = "worldmap";
    >
    > whichMap[1] = new Array();
    > whichMap[1][0] = "North America";
    > whichMap[1][1] = "/atctestsite/affiliates/gifs/northamerica.gi f";
    > whichMap[1][2] = "northameri ca";
    >
    > whichMap[2] = new Array();
    > whichMap[2][0] = "United States";
    > whichMap[2][1] = "/atctestsite/affiliates/gifs/usa_color.gif";
    > whichMap[2][2] = "unitedstat es";
    > }
    > </script>
    >
    > Now, with this defined, I should be able to choose which one to use,
    > and change the objects in the body of the document to the resulting
    > values. The problem is, I'm having trouble finding a good description
    > of how to define objects like Headers and imagemaps. I would like to
    > be able to use the basic document objects, but if I create the header
    > like this:
    >
    > <h1 name="title1">W orld Map</h1>
    >
    > how do I change that to either "North America" or "United States" if
    > the correct link is chosen? I can see that this will be a function
    > call, probably called when the onclick() event is seen, but I'm
    > getting lost how to go any further.
    >
    > Anyone have any ideas?
    >
    > Chad Lupkes
    > chadlupkes@eart hlink.net[/color]


    Comment

    Working...