473,322 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to add a property to an object at runtime

Is there a way to add a property to a javascript object at runtime if
you don't the name until runtime?

For Example:

var oTestObj = new Object();
//In the real world the value of sPropertyName would be calculated.
var sPropertyName = "NewProperty";

//How do you add a property whos name is the value of sPropertyName?

oTestObj.NewProperty = "Somevalue";

Sep 9 '05 #1
2 3686
oTestObj[sProperty]="Somevalue";

Sep 9 '05 #2

Correct, obj[WHATEVER IS THE STDOUT/output EXPANDED HERE].someprophere;

Danny
Sep 10 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: CharlesEF | last post by:
Hi All, This has me stumped. I have used a VBScript dictionary object to load column names and their values so I can use them when I build the web page. When I do this, I get the correct...
1
by: windandwaves | last post by:
Hi Folk I am working with the TYPE property. I want to change that from 2 (byte) to 4 (long integer) for a field that already contains tons of data. How can I do that? The help reads: ...
2
by: Luis Arvayo | last post by:
Is there some way to attach an editor to a property of a class at runtime ? Ex.; public class MyClass { public int BitmapIndex
0
by: Henrik de Jong | last post by:
Some additional information: I've got an business-object wich has a property Value wich will retreive the value of a databasefield. To bind this object to an datagrid this object should...
8
by: | last post by:
In VB6 there was a property - object. What is the similar property in .NET I am using a 3rd party COM grid object that requests the object property of another such object. e;g: Set grd.ddb =...
2
by: Jason Richmeier | last post by:
Perhaps it is because it is the end of the day and my eyes are tired of looking at code but I cannot seem to figure out what I am doing wrong and what I can do (if anything) to fix it. On a...
2
by: iwdu15 | last post by:
Hi, im making a tool used to Skin controls. Im trying to make it so a user can change any property they want by passing the property in....for example Public Sub ChangeProperty(Byval Prop as...
2
by: Ray Cassick | last post by:
I am looking for a way to hide a property I created on a user control from a property grid at runtime but allow it to be seen at design time. Any ideas? I tried setting the category of the...
3
by: Peter Gast | last post by:
Hi, I need as a parameter for a control the names of my properties as a string. How can I get the name of the property as a string during runtime Example: Private _MyVar As Double Public...
3
by: Udi | last post by:
Hi All, I have an object that is reflected at runtime by Windows script host engine, so its public methods and properties can then be used from within a script. Based on a certain condition, I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.