PDA

View Full Version : [AS] HELP. Variables and Loops issue.


vontiger
11-05-2003, 08:07 AM
Hi All,

I'm trying to create a loop that changes variables.
for (var i = 0; i < antal_rubriker; i++) {

// What I'm traying to do here is to the first time it loops
// the variable punkt is punkt1 the next time it's punkt2 etc.
// So when it will create an element it is:
// var punkt1 = menyDP.createElement("node");
// and the next time it's:
// var punkt2 = menyDP.createElement("node");

var punkt_var = "punkt" + i;
var punkt = punkt_var;
var punkt = menyDP.createElement("node");

// In a seperat text file there is variables i.e. rubrik1=text1&
// rubrik2=text2&rubrik3=text3. So what I want to happend
// that the punkt.attributs.label = text1 and so on.
// Also that punkt is punkt1.att, punkt2.att and so on.

var rubrik_var = (rubrik + i);
var rubrik = rubrik_var;
punkt.attributes.label = rubrik;
punkt.attributes.data = 0 + i;
}

Jesse
11-06-2003, 01:25 AM
[useastags]

for (var i = 0; i < antal_rubriker; i++) {
this["punkt" + i] = menyDP.createElement("node");
}

See the Advanced Pathing tutorial for more information on dynamic pathing, which is the issue you are asking about.