User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 29 Oct 2002, 12:37   #1
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Question Javascript: variable variable names

Is there such thing as a variable variable-name in JavaScript? Google doesn't seem to be my friend today.
If so, how do I use it?
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 29 Oct 2002, 13:04   #2
CjC
Throwing Shapes
 
CjC's Avatar
 
Join Date: Apr 2000
Posts: 797
CjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant futureCjC has a brilliant future
You could try to script ASP into Java which would effectively give a variable from a string in a vb variable.

Ie
Code:
<%Dim vbVar
vbVar = "fieldnamehere"%>
<script language="Javascript">

function test()

     {var <%response.write(vbVar)%> = whatever}

</script>
Would that help?
__________________
Time is an Illusion, Lunchtime doubly so.
CjC is offline   Reply With Quote
Unread 29 Oct 2002, 13:14   #3
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
Perhaps...
=/

What I'm trying to do is doing an operation on a load of style properties:
ie, change their X and Y position

The problem is I don't know in advance how many of these object are on a page.... could be 2, could be 10, could be a 1000...

I have also tried making an array of these objects, but that doesn't seem to work either:

Pobj = new Array(document.all.p1, docment.all.p2)

When I do an operation on their style property I get an error, telling me there is no such thing as a style property.

What I'm trying to prevent is a huge list of objects in my function (if I'd make it dynamically with ASP), because 1) that would eat quite some bandwidth 2) my ASP server wouldn't like that a lot.
__________________
"Yay"
Structural Integrity is offline   Reply With Quote
Unread 29 Oct 2002, 20:20   #4
Atamur
Ngisne
 
Join Date: Jul 2001
Location: right here
Posts: 79
Atamur is an unknown quantity at this point
to answer your original question, you can evaluate an expression (which can be just a variable name) with eval function. e.g.
Code:
a5="hello"
document.write(eval("a1"))
However, for what you are trying to do, there's a method getElementById() in document object. So to access style of something with ID "p2", you can do
Code:
document.getElementById("p2").style
This is a much better way to do things anyways because document.all is non-standard and only supported by IE. getElementById is part of DOM standard and is supported both by IE (>= 5.5) and mozilla.
__________________
down with signatures
Atamur is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 23:55.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018