Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > Re: naming arra...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 35476 of 37633
Post > Topic >>

Re: naming array values?

by Thomas 'PointedEars' Lahn <PointedEars@[EMAIL PROTECTED] > May 7, 2008 at 12:02 AM

Pukeko wrote:
> Hi, this is an array that is used for a dropdown menu.

From your question below I surmise you are probably talking about a
`select'
element that only works with present and enabled client-side script
sup****t,
which would be a really bad idea.

> var imageArray = new Array(
> 	"ecwp://" + do***ent.location.host + "/massey/images/massey/
> massey_07_fullres.ecw",

do***ent.location has been deprecated more than 10 years ago.

> 	"ecwp://" + do***ent.location.host + "/sampleiws/images/usa/
> 1metercalif.ecw",
> 	"ecwp://" + do***ent.location.host + "/sampleiws/images/australia/
> parramatta.ecw";

Your source code is syntactically incorrect: the closing `)' for the
constructor call is missing.  That aside, I would do at least:

  var imageArray = new Array(
    new Array("ecwp://", "/massey/images/massey/massey_07_fullres.ecw"),
    new Array("ecwp://", "/sampleiws/images/usa/1metercalif.ecw"),
    new Array("ecwp://", "/sampleiws/images/australia/parramatta.ecw")
  );

  for (var i = 0, len = imageArray.length; i < len; i++)
  {
    imageArray[i] = imageArray[i].join(do***ent.location.host);
  }

> 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"

Yes, there is, for example by using your own constructor:

  /**
   * Constructs a new <code>Item</code> object.
   *
   * @[EMAIL PROTECTED]
 uriParts: Array
   *   2-element array containing the scheme and the path of
   *   the target URI.  The parts are joined with the host name
   *   of the URL of the current do***ent.
   * @[EMAIL PROTECTED]
 text: optional string
   *   Text for the menu item; the default is the target URI.
   * @[EMAIL PROTECTED]
   */
  function Item(uriParts, text)
  {
    /**
     * URI of the target resource
     */
    this.uri = uriParts.join(window.location.host);

    /**
     * Text for the menu item
     */
    this.text = text || this.uri;
  }

  var imageArray = new Array(
    new Item(
      new Array("ecwp://", "/massey/images/massey/massey_07_fullres.ecw"),
      "Massey 2007"
    ),
    ...
  );

You should then get informed how HTML `select' and `option' elements work,
or RTFM of your "menu" script of which you have not even posted the
relevant
parts here.


PointedEars
-- 
    realism:    HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness:    XHTML 1.1 as application/xhtml+xml
                                                    -- Bjoern Hoehrmann
 




 6 Posts in Topic:
naming array values?
Pukeko <pukeko.taniwha  2008-05-04 21:29:23 
Re: naming array values?
"Tim Williams"   2008-05-04 23:24:57 
Re: naming array values?
Tom Cole <tcole6@[EMAI  2008-05-05 05:26:37 
Re: naming array values?
unbewusst.sein@[EMAIL PRO  2008-05-05 15:05:50 
Re: naming array values?
Thomas 'PointedEars' Lahn  2008-05-07 00:26:31 
Re: naming array values?
Thomas 'PointedEars' Lahn  2008-05-07 00:02:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 22:11:30 CST 2008.