Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can I use variables in Javascript object names?




On 01/11/2006, at 9:45 PM, Neil Taylor wrote:
In your example code, 'Day1' is a string and therefore does not have the .name property. If you are trying to access an element that has the name: 'dateDay1_year', then you can use eName (without .name). The document.getElementById() will find the correct element.

Thanks Neil, the explanation did the trick. I puzzled over the HTML for a while and finally saw that the HTML code contained names not IDs!!





On Wednesday, November 01, 2006, at 02:23AM, "Malcolm Fitzgerald" <email@hidden> wrote:

On 01/11/2006, at 12:14 PM, Marcelo Alves wrote:
Try :

function displayDate(eName) {
  var yy = 'date' + eName.name + "_year";
  var yyIndex = document.getElementById(yy).selectedIndex;
}

When I call displayDate('Day1') eName is 'Day1' and eName.name is undefined. yy ends up being "dateUndefined_year"


_______________________________________________ Do not post admin requests to the list. They will be ignored. Web-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.