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.
Michael Easter
24.6k9 gold badges81 silver badges111 bronze badges
asked Dec 8, 2011 at 19:42
Nader Khan
1882 gold badges8 silver badges18 bronze badges
1 Answer 1
Why don't you use arrays?
forloop{
tasks[taskID] = MainGanttTask(taskID...)
}
forloop{
tasks[taskID].addChild(childTaskID...)
}
answered Dec 8, 2011 at 19:44
Emre Erkan
8,4723 gold badges52 silver badges55 bronze badges
Sign up to request clarification or add additional context in comments.
5 Comments
Nader Khan
thanx for your reply, but the jquery plugin that i am using, doesn't accept array, needs the input for the task name to be a variable.
Emre Erkan
What is that plugin? If we know maybe we can help you more.
Nader Khan
not really a plugin. a class which i customized, got it from dhtmlx.com/docs/products/dhtmlxChart/index.shtml
Nader Khan
solved. just needed to declare the array before using it. thanx
Emre Erkan
lang-js