On May 5, 2:24=A0am, "Tim Williams" <timjwilliams at gmail dot com>
wrote:
> "Pukeko" <pukeko.tani...@[EMAIL PROTECTED]
> wrote in message
>
>
news:eab0f478-cfc2-483f-b888-e095d4c2dbee@[EMAIL PROTECTED]
>
>
>
>
>
> > Hi, this is an array that is used for a dropdown menu.
>
> > var imageArray =3D new Array(
> > "ecwp://" + do***ent.location.host + "/massey/images/massey/
> > massey_07_fullres.ecw",
> > "ecwp://" + do***ent.location.host + "/sampleiws/images/usa/
> > 1metercalif.ecw",
> > "ecwp://" + do***ent.location.host + "/sampleiws/images/australia/
> > parramatta.ecw";
>
> > when the menu is displayed it shows the whole value
>
> > "ecwp://" + do***ent.location.host + "/massey/images/massey/
> > massey_07_fullres.ecw""
>
> > is there a way i can just display a name for the image in the dropdown
> > menu, like "Massey 2007"
>
> > cheers
>
> How are you building the menu ? =A0If you have code to do that (and it's
> always useful to include that in your post), then just adjust to suit.
>
> Otherwise, you haven't provided enough information to answer your
queston.=
>
> Tim- Hide quoted text -
>
> - Show quoted text -
Javascript arrays are a little tricky in this regards. Yes you can
"name" and Array entry, or more accurately assign a "name" as the key.
The problem is, in my experience, that when store array elements in
this manner, the length of the array is not adjusted. For example this
is totally legit:
var images =3D new Array();
images['Massey 2007'] =3D "ecwp://" + do***ent.location.host + "/massey/
images/massey/massey_07_fullres.ecw";
images['Massey 2006'] =3D "ecwp://" + do***ent.location.host + "/massey/
images/massey/massey_06_fullres.ecw";
However if you call alert(images.length) you will get 0. Of course
even if it didn't, this wouldn't help, because you need the key (or
"name") not just the value. And there is no method that I have found
to retrieve the list of keys an array is using. So...the problem isn't
"naming" your array elements, but how do you remember that list of
names so you can later retrieve the values.
You will probably need two arrays, one to store the "names" and the
other to store the "values". How you arrange to coordinate the two are
up to you. You could simply ensure that both arrays are the same
length and that the element 0 in the names array correlates to the
element 0 in the values array, or you could keep the names in array 1
and use the names as the keys in array 2. For example:
var names =3D new Array();
var urls =3D new Array();
names.push("Massey 2007");
urls["Massey 2007"] =3D "ecwp://" + do***ent.location.host + "/massey/
images/massey/massey_07_fullres.ecw";
Then you could loop through the names array and pull the url using
that value as the key from the second array. For example:
for (var i =3D 0; i < names.length; i++) {
var name =3D names[i];
var url =3D urls[name];
//build your Option here...
}
HTH...


|