Nader Khan
Nader Khan

Reputation: 188

dynamic jQuery variable name

I am working on generating gantt chart using jquery. Have searched alot, but didn't reach any conclusion on if it is possible to declare a dynamic jquery variable. Here is a sample of what I am trying to do:

First, I am trying to generate a dynamic main task from the database. I want to make the variable name dynamic so that i can dynamically assign it subtasks. want to do somthing like:

forloop{
var task+taskID = MainGanttTask(taskID...)
}

forloop{
task+taskID.addChild(childTaskID...)
}

So, is there any way to get my "task+taskID" variable working?

Thanx in advance.

Upvotes: 0

Views: 725

Answers (1)

Emre Erkan
Emre Erkan

Reputation: 8482

Why don't you use arrays?

forloop{
    tasks[taskID] = MainGanttTask(taskID...)
}

forloop{
    tasks[taskID].addChild(childTaskID...)
}

Upvotes: 1

Related Questions