www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] Use Variable Value as the Object Property

  1. #1
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,132

    resolved [RESOLVED] Use Variable Value as the Object Property

    Greetings, I hope I worded this correctly. I'm trying to use a variable value as the object property name. For example:

    var order = new Object();
    order.orderid = 12345;

    The problem is, orderid is stored as a value in another string. For example:

    var propertyName = 'orderid';
    var order = new Object();
    order.propertyName = 12345;

    How can I set order.orderid equal to something when "orderid" is stored in a variable?
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,132
    I've solved it:

    Code:
    var propertyName = 'orderid';
    var order = new Object();
    order[propertyName] = 12345;
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles