WBS - Work Breakdown Structure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    WBS - Work Breakdown Structure

    Hello I am working on WorkBreak Down structures, but i was unable to finish it perfectly. I am posting my code with this. I have to finish this task. please help me out.

    It must form like this

    WBS TaskID No. of Resource St.Date End.Date Duration
    1 asdkfa 2 asdfasd asdfdas asdf
    1.1 asdkfa 2 asdfasd asdfdas asdf
    2 asdkfa 2 asdfasd asdfdas asdf
    2.1 asdkfa 2 asdfasd asdfdas asdf
    2.2 asdkfa 2 asdfasd asdfdas asdf

    Like this I have to form dynamically
    The code I had developed is

    [HTML]<html>
    <head>
    <script src="Cal.js" type="text/javascript"></script>
    <script type="text/javascript">
    i=1;
    j=1;
    var ww=new Array();
    ww[0]=0;
    ww[1]=0;

    var taskno=0;
    var subirow;
    var subtaskno;
    var fl=0;
    var zx;
    function insSubRow(q)
    {

    i++;
    ww[i]=0;
    var xx =q.parentNode.p arentNode.rowIn dex;
    indx(xx)
    var table = document.getEle mentById("myTab le");
    var row = table.rows[xx];
    var cell = row.cells[0];
    var az = cell.firstChild .nodeValue;
    if(fl==0)
    {
    subirow=xx;
    zx=xx;
    zx++;
    fl=1;
    subtaskno=0;
    }
    else
    {
    if(subirow==xx)
    {
    zx++;
    }
    else
    {
    subtaskno=0;
    subirow=xx;
    zx=xx;
    zx++;
    }
    }
    var x=document.getE lementById('myT able').insertRo w(zx);
    var b=x.insertCell( 0);
    subtaskno = subtaskno+1;
    temp = az+"."+subtaskn o;
    b.innerHTML = temp;
    var c=x.insertCell( 1);
    c.innerHTML = "&nbsp&nbsp&nbs p&nbsp&nbsp&nbs p&nbsp&nbsp&nbs p"+'<input type="text" size="20">'+"&n bsp&nbsp"+'<inp ut type="button" value="remove" onclick="delete Row(this,0)">';
    var a=x.insertCell( 2);
    a.innerHTML='<i nput type="text" size="10">';
    var a=x.insertCell( 3);
    a.innerHTML='<s elect><option>H igh</option><option> Medium</option><option> Low</option></select>';
    var a=x.insertCell( 4);
    a.innerHTML='<s elect><option>y es</option><option> no</option></select>';
    var a=x.insertCell( 5);
    a.innerHTML='<s elect><option>A ssigned</option><option> On Track</option><option> Late</option><option> Complete</option></select>';
    var a=x.insertCell( 6);
    a.innerHTML='<i nput type="text" size="10" onclick="scwSho w(this,event)"> ';
    var a=x.insertCell( 7);
    a.innerHTML='<i nput type="text" size="10" onclick="scwSho w(this,event)"> ';
    var a=x.insertCell( 8);
    a.innerHTML='<i nput type="text" size="10">';
    }
    function insRow(p)
    {
    ww[i]=0;

    var x=document.getE lementById('myT able').insertRo w(i);
    var b=x.insertCell( 0);
    taskno = taskno+1;
    b.innerHTML = taskno;
    var c=x.insertCell( 1);
    c.innerHTML = '<input type="text" size="15">'+"&n bsp&nbsp&nbsp"+ '<input type="button" value="Sub Task" onclick="insSub Row(this)">'+"& nbsp&nbsp"+'<in put type="button" value="remove" onclick="delete Row(this,1)">';
    var a=x.insertCell( 2);
    a.innerHTML='<i nput type="text" size="10">';
    var a=x.insertCell( 3);
    a.innerHTML='<s elect><option>H igh</option><option> Medium</option><option> Low</option></select>';
    var a=x.insertCell( 4);
    a.innerHTML='<s elect><option>y es</option><option> no</option></select>';
    var a=x.insertCell( 5);
    a.innerHTML='<s elect><option>A ssigned</option><option> On Track</option><option> Late</option><option> Complete</option></select>';
    var a=x.insertCell( 6);
    a.innerHTML='<i nput type="text" size="10" onclick="scwSho w(this,event)"> ';
    var a=x.insertCell( 7);
    a.innerHTML='<i nput type="text" size="10" onclick="scwSho w(this,event)"> ';
    var a=x.insertCell( 8);
    a.innerHTML='<i nput type="text" size="10">';
    i++;
    }
    function indx(jk)
    {
    jj=jk;
    k=ww[jj];
    k++;
    ww[jj]=k;
    }
    function deleteRow(r,f)
    {

    var jj=r.parentNode .parentNode.row Index;
    if(f==0)
    {
    document.getEle mentById('myTab le').deleteRow( jj);
    i--;
    zx--;
    }
    else
    {


    for(m=ww[jj]+jj;m>=jj;m--)
    {

    document.getEle mentById('myTab le').deleteRow( jj);
    i--;
    zx--;
    }
    j--;
    }

    }
    </script>
    </head>
    <body>
    <p><p><p><p>
    &nbsp&nbsp<inpu t type="button" onclick="insRow (this)" value="Add Task">
    <p><p><p><p>
    <table id="myTable" frame="hsides" align="center" border="3" cellspacing="0" cellpading="0" width="1000">
    <tr >
    <th>WBS</th>
    <th width="399">Tas k Id</th>

    <th>Task Name</th>
    <th>Priority</th>
    <th>Active</th>
    <th>Status</th>
    <th>St. Date</th>
    <th>End Date</th>
    <th>Total Hrs.</th>
    </tr>
    </table>
    </table>
    </body>
    </html>[/HTML]

    Please Help me out guys. It's very very urgent
    Last edited by gits; Mar 10 '08, 12:46 PM. Reason: added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    So what happens? What works and what doesn't?

    Comment

    • RamananKalirajan
      Contributor
      • Mar 2008
      • 608

      #3
      Originally posted by acoder
      So what happens? What works and what doesn't?
      Hello the code is working cool but the problem is. If I am incrementing the subindex of an index and after I am trying the same for other means it's ok. If again i work on the first its get collapsed. Moreover if I am deleting a sub index or index the numberings are more worse i can't frame the correct numbering. Please help me out. You just run the code in HTML then you can find the problem

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by RamananKaliraja n
        Hello the code is working cool but the problem is. If I am incrementing the subindex of an index and after I am trying the same for other means it's ok. If again i work on the first its get collapsed. Moreover if I am deleting a sub index or index the numberings are more worse i can't frame the correct numbering. Please help me out. You just run the code in HTML then you can find the problem
        You're using the global variable taskno which you're not updating. You need to update it when deleting a row.

        Comment

        • RamananKalirajan
          Contributor
          • Mar 2008
          • 608

          #5
          Originally posted by acoder
          You're using the global variable taskno which you're not updating. You need to update it when deleting a row.
          If I am deleting task means i have to decrement the index no, but doing so I face many problems if I delete the tasks inbetween. Please help me out if you have any better way to do this task what i had developed is seems to be complex one

          Regards
          Ramanan

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            One way to solve that problem is to copy the lower tasks (below the row to be deleted) to the higher ones, i.e. move them all up one row, then delete the last row. That way all the numbers can remain as they are.

            Comment

            • RamananKalirajan
              Contributor
              • Mar 2008
              • 608

              #7
              Originally posted by acoder
              One way to solve that problem is to copy the lower tasks (below the row to be deleted) to the higher ones, i.e. move them all up one row, then delete the last row. That way all the numbers can remain as they are.
              I am sorry to ask this but I have no other go, are you having any code that matches my requirement. That is creating the WBS (Work Break Down Structure) dynamically with the task's and subtask's. That works in the same fashion what i had did. If you have means please help me out.

              Regards
              Ramanan Kalirajan

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                I don't, but this example might help.

                I can help modify your existing code, but I can't give you the whole working code.

                Comment

                • RamananKalirajan
                  Contributor
                  • Mar 2008
                  • 608

                  #9
                  Originally posted by acoder
                  I don't, but this example might help.

                  I can help modify your existing code, but I can't give you the whole working code.
                  Thank you very much Mr. Acoder, I think that example would be really helpful for me. Let me try that example in my code.

                  Regards
                  Ramanan Kalirajan

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Good luck and post back if you need more help or with the final solution.

                    Comment

                    • RamananKalirajan
                      Contributor
                      • Mar 2008
                      • 608

                      #11
                      Originally posted by acoder
                      Good luck and post back if you need more help or with the final solution.
                      Hello Sir, I am working on the WBS structure i am trying to finsih it. I post the code which I had done till now:

                      [HTML]<html>
                      <head>
                      <script language="javas cript">
                      var taskno=0;
                      var ROW_BASE=1;
                      function addTask()
                      {
                      var oTable=document .getElementById ('myTable');
                      var lastRow = oTable.rows.len gth;
                      var row=oTable.inse rtRow(lastRow);

                      //create WBS Cell
                      oCell = row.insertCell( 0);
                      var el = document.create Element('input' );
                      el.type="text";
                      el.size="5";
                      taskno++;
                      el.value=taskno ;
                      oCell.appendChi ld(el);
                      oCell.innerHTML =oCell.innerHTM L;

                      //Task Name
                      oCell = row.insertCell( 1);
                      var el1 = document.create Element('input' );
                      el1.type="text" ;
                      el1.size="25";
                      oCell.appendChi ld(el1);
                      oCell.innerHTML =oCell.innerHTM L;

                      //Adding SubTask
                      oCell = row.insertCell( 2);
                      var el2 = document.create Element('input' );
                      el2.type="butto n";
                      el2.value="Sub Task";
                      el2.onclick="ad dSubTask(this)" ;
                      oCell.appendChi ld(el2);
                      oCell.innerHTML =oCell.innerHTM L;

                      //Remove Button
                      oCell = row.insertCell( 3);
                      var el3 = document.create Element('input' );
                      el3.type="butto n";
                      el3.value="Remo ve";
                      el3.onclick="re moveThis(this)" ;
                      oCell.appendChi ld(el3);
                      oCell.innerHTML =oCell.innerHTM L;
                      }
                      function addSubTask(rowe l)
                      {
                      var temp;
                      var insert;
                      var subRow = rowel.parentNod e.parentNode;
                      var tbl = subRow.parentNo de.parentNode;
                      var ri = subRow.sectionR owIndex;
                      var nval = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                      alert(nval);
                      var x=ri+1;
                      var nval1;
                      alert(ri);
                      alert(document. getElementById( 'myTable').rows .length);
                      if(ri==(documen t.getElementByI d('myTable').ro ws.length-1))
                      {
                      nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                      }
                      else
                      {
                      nval1 = tbl.tBodies[0].rows[x].cells[0].firstChild.val ue;
                      }
                      var str=nval1+"";
                      flag="TRUE";
                      if(str.indexOf( ".")==-1)
                      {
                      var subtaskno=1;
                      temp =nval+"."+subta skno;
                      insert=ri+1;
                      }
                      else
                      {
                      while(flag=="TR UE")
                      {
                      ri=ri+1;
                      alert("Inside while "+ri);
                      alert("Table length = "+document.getE lementById('myT able').rows.len gth);
                      if(ri==(documen t.getElementByI d('myTable').ro ws.length))
                      {
                      nval1 = tbl.tBodies[0].rows[ri-1].cells[0].firstChild.val ue;
                      alert("Inside While If");
                      flag="FALSE";
                      ri=ri-1;
                      str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                      subtaskno=str.s ubstring (str.lastIndexO f (".")+1, str.length);
                      var stask = parseInt(subtas kno);
                      stask=stask+1;
                      temp =nval+"."+stask ;
                      }
                      else
                      {
                      nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                      }
                      alert(nval1);
                      var str=nval1+"";
                      if(str.indexOf( ".")==-1)
                      {
                      flag="FALSE";
                      ri=ri-1;
                      str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                      subtaskno=str.s ubstring (str.lastIndexO f (".")+1, str.length);
                      var stask = parseInt(subtas kno);
                      stask=stask+1;
                      temp =nval+"."+stask ;
                      }
                      else
                      {
                      flag=="TRUE" ;
                      }
                      }
                      insert=ri+1;
                      }

                      var oTable=document .getElementById ('myTable');
                      var row=oTable.inse rtRow(insert);

                      //create WBS Cell
                      oCell = row.insertCell( 0);
                      var el = document.create Element('input' );
                      el.type="text";
                      el.size="5";
                      el.value=temp;
                      oCell.appendChi ld(el);
                      oCell.innerHTML =oCell.innerHTM L;

                      //Task Name
                      oCell = row.insertCell( 1);
                      var el1 = document.create Element('input' );
                      el1.type="text" ;
                      el1.size="25";
                      oCell.appendChi ld(el1);
                      oCell.innerHTML =oCell.innerHTM L;

                      //Adding SubTask
                      oCell = row.insertCell( 2);
                      var el2 = document.create Element('input' );
                      el2.type="butto n";
                      el2.value="Temp ";
                      el2.onclick="sh owTemp(this)";
                      oCell.appendChi ld(el2);
                      oCell.innerHTML =oCell.innerHTM L;

                      //Remove Button
                      oCell = row.insertCell( 3);
                      var el3 = document.create Element('input' );
                      el3.type="butto n";
                      el3.value="Remo ve";
                      el3.onclick="re moveThis(this)" ;
                      oCell.appendChi ld(el3);
                      oCell.innerHTML =oCell.innerHTM L;
                      }
                      function showTemp(rowel)
                      {
                      alert("This is temp");
                      }
                      function removeThis(rowe l)
                      {
                      var delRow = rowel.parentNod e.parentNode;
                      var tbl = delRow.parentNo de.parentNode;
                      var rIndex = delRow.sectionR owIndex;
                      var nval = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                      alert(nval);
                      var str=nval;
                      if(str.indexOf( ".")==-1)
                      {
                      taskno--;
                      var rowArray = new Array(delRow);
                      deleteRows(rowA rray);
                      reorderRows(tbl , rIndex);
                      }
                      else
                      {
                      document.getEle mentById('myTab le').deleteRow( rIndex);
                      }
                      }
                      function reorderRows(tbl , startingIndex)
                      {
                      var table = document.getEle mentById('myTab le');
                      if (tbl.tBodies[0].rows[startingIndex]) {
                      var count = startingIndex;
                      for (var i=startingIndex ; i<tbl.tBodies[0].rows.length; i++) {
                      tbl.tBodies[0].rows[i].cells[0].firstChild.val ue= count;
                      count++;
                      }
                      }

                      }
                      function deleteRows(rowO bjArray)
                      {
                      for (var i=0; i<rowObjArray.l ength; i++) {
                      var rIndex = rowObjArray[i].sectionRowInde x;
                      rowObjArray[i].parentNode.del eteRow(rIndex);
                      }
                      }
                      </script>
                      </head>
                      <body>
                      <br/>
                      <input type="button" value="Add Task" onclick="addTas k()">
                      <br/>
                      <table id='myTable'>
                      <tr>
                      <th>WBS</th>
                      <th>Task Name</th>
                      <th></th>
                      <th></th>
                      </tr>
                      </table>
                      </body>
                      </html>[/HTML]

                      Please give me your comments that will help me in molding myself

                      Regards
                      Ramanan Kalirajan

                      Comment

                      • RamananKalirajan
                        Contributor
                        • Mar 2008
                        • 608

                        #12
                        Hello Sir, I had did most of the things. The remaining work which is pending is if delete a task, the sub tasks under that tasks must be deleted I am working on that Surely I will finish it. I give the code which is working till creating task, subtask, deleting and reordering.

                        [HTML]<html>
                        <head>
                        <script language="javas cript">
                        var taskno=0;
                        var ROW_BASE=1;
                        function addTask()
                        {
                        var oTable=document .getElementById ('myTable');
                        var lastRow = oTable.rows.len gth;
                        var row=oTable.inse rtRow(lastRow);

                        //create WBS Cell
                        oCell = row.insertCell( 0);
                        var el = document.create Element('input' );
                        el.type="text";
                        el.size="5";
                        taskno++;
                        el.value=taskno ;
                        oCell.appendChi ld(el);
                        oCell.innerHTML =oCell.innerHTM L;

                        //Task Name
                        oCell = row.insertCell( 1);
                        var el1 = document.create Element('input' );
                        el1.type="text" ;
                        el1.size="25";
                        oCell.appendChi ld(el1);
                        oCell.innerHTML =oCell.innerHTM L;

                        //Adding SubTask
                        oCell = row.insertCell( 2);
                        var el2 = document.create Element('input' );
                        el2.type="butto n";
                        el2.value="Sub Task";
                        el2.onclick="ad dSubTask(this)" ;
                        oCell.appendChi ld(el2);
                        oCell.innerHTML =oCell.innerHTM L;

                        //Remove Button
                        oCell = row.insertCell( 3);
                        var el3 = document.create Element('input' );
                        el3.type="butto n";
                        el3.value="Remo ve";
                        el3.onclick="re moveThis(this)" ;
                        oCell.appendChi ld(el3);
                        oCell.innerHTML =oCell.innerHTM L;
                        }
                        function addSubTask(rowe l)
                        {
                        var temp;
                        var insert;
                        var subRow = rowel.parentNod e.parentNode;
                        var tbl = subRow.parentNo de.parentNode;
                        var ri = subRow.sectionR owIndex;
                        var nval = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                        var x=ri+1;
                        var nval1;
                        if(ri==(documen t.getElementByI d('myTable').ro ws.length-1))
                        {
                        nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                        }
                        else
                        {
                        nval1 = tbl.tBodies[0].rows[x].cells[0].firstChild.val ue;
                        }
                        var str=nval1+"";
                        flag="TRUE";
                        if(str.indexOf( ".")==-1)
                        {
                        var subtaskno=1;
                        temp =nval+"."+subta skno;
                        insert=ri+1;
                        }
                        else
                        {
                        while(flag=="TR UE")
                        {
                        ri=ri+1;
                        if(ri==(documen t.getElementByI d('myTable').ro ws.length))
                        {
                        nval1 = tbl.tBodies[0].rows[ri-1].cells[0].firstChild.val ue;
                        flag="FALSE";
                        ri=ri-1;
                        str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                        subtaskno=str.s ubstring (str.lastIndexO f (".")+1, str.length);
                        var stask = parseInt(subtas kno);
                        stask=stask+1;
                        temp =nval+"."+stask ;
                        }
                        else
                        {
                        nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                        }
                        var str=nval1+"";
                        if(str.indexOf( ".")==-1)
                        {
                        flag="FALSE";
                        ri=ri-1;
                        str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                        subtaskno=str.s ubstring (str.lastIndexO f (".")+1, str.length);
                        var stask = parseInt(subtas kno);
                        stask=stask+1;
                        temp =nval+"."+stask ;
                        }
                        else
                        {
                        flag=="TRUE" ;
                        }
                        }
                        insert=ri+1;
                        }

                        var oTable=document .getElementById ('myTable');
                        var row=oTable.inse rtRow(insert);

                        //create WBS Cell
                        oCell = row.insertCell( 0);
                        var el = document.create Element('input' );
                        el.type="text";
                        el.size="5";
                        el.value=temp;
                        oCell.appendChi ld(el);
                        oCell.innerHTML =oCell.innerHTM L;

                        //Task Name
                        oCell = row.insertCell( 1);
                        var el1 = document.create Element('input' );
                        el1.type="text" ;
                        el1.size="25";
                        oCell.appendChi ld(el1);
                        oCell.innerHTML =oCell.innerHTM L;

                        //Adding SubTask
                        oCell = row.insertCell( 2);
                        var el2 = document.create Element('input' );
                        el2.type="butto n";
                        el2.value="Temp ";
                        el2.onclick="sh owTemp(this)";
                        oCell.appendChi ld(el2);
                        oCell.innerHTML =oCell.innerHTM L;

                        //Remove Button
                        oCell = row.insertCell( 3);
                        var el3 = document.create Element('input' );
                        el3.type="butto n";
                        el3.value="Remo ve";
                        el3.onclick="re moveThis(this)" ;
                        oCell.appendChi ld(el3);
                        oCell.innerHTML =oCell.innerHTM L;
                        }
                        function showTemp(rowel)
                        {
                        alert("This is temp");
                        }
                        function removeThis(rowe l)
                        {
                        var delRow = rowel.parentNod e.parentNode;
                        var tbl = delRow.parentNo de.parentNode;
                        var rIndex = delRow.sectionR owIndex;
                        var nval = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                        var str=nval;
                        if(str.indexOf( ".")==-1)
                        {
                        taskno--;
                        var rowArray = new Array(delRow);
                        deleteRows(rowA rray);
                        reorder();
                        }
                        else
                        {
                        document.getEle mentById('myTab le').deleteRow( rIndex);
                        if(rIndex==docu ment.getElement ById('myTable') .rows.length)
                        {
                        flag1=="FALSE";
                        }
                        else
                        {
                        var flag1="TRUE";
                        while(flag1=="T RUE")
                        {
                        if(rIndex==docu ment.getElement ById('myTable') .rows.length)
                        {
                        return;
                        }
                        var x = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                        var y=x+"";
                        if(y.indexOf(". ")==-1)
                        {
                        flag1="false";
                        }
                        else
                        {
                        tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue=nval;
                        nval=y;
                        rIndex= rIndex+1;
                        }

                        }
                        }
                        }
                        }
                        var lastValue;
                        function reorder()
                        {
                        var len=document.ge tElementById('m yTable').rows.l ength;
                        var tbl = document.getEle mentById('myTab le');
                        i=0;
                        tbl.tBodies[0].rows[1].cells[0].firstChild.val ue=1;
                        lastValue=tbl.t Bodies[0].rows[1].cells[0].firstChild.val ue;
                        var taskno=0;
                        i=2;
                        do
                        {
                        var x = tbl.tBodies[0].rows[i].cells[0].firstChild.val ue;
                        var y= x+"";
                        if(y.indexOf(". ")==-1)
                        {
                        lastValue=parse Int(lastValue)+ 1;
                        tbl.tBodies[0].rows[i].cells[0].firstChild.val ue=lastValue;
                        lastValue= tbl.tBodies[0].rows[i].cells[0].firstChild.val ue;
                        taskno=0;
                        }
                        else
                        {
                        taskno=taskno+1 ;
                        var temp = lastValue+"."+t askno;
                        tbl.tBodies[0].rows[i].cells[0].firstChild.val ue=temp;
                        }
                        i=i+1;
                        }
                        while(i<len);

                        }
                        function deleteRows(rowO bjArray)
                        {
                        for (var i=0; i<rowObjArray.l ength; i++) {
                        var rIndex = rowObjArray[i].sectionRowInde x;
                        rowObjArray[i].parentNode.del eteRow(rIndex);
                        }
                        }
                        </script>
                        </head>
                        <body>
                        <br/>
                        <input type="button" value="Add Task" onclick="addTas k()">
                        <br/>
                        <table id='myTable'>
                        <tr>
                        <th>WBS</th>
                        <th>Task Name</th>
                        <th></th>
                        <th></th>
                        </tr>
                        </table>
                        </body>
                        </html>[/HTML]

                        Regards
                        Ramanan Kalirajan

                        Comment

                        • RamananKalirajan
                          Contributor
                          • Mar 2008
                          • 608

                          #13
                          Hello Sir, a happy news i had created the full working code for WBS with creating Task, Subtask, deleting and reordering dynamically. The Following is the code:

                          [HTML]<html>
                          <head>
                          <script language="javas cript">
                          var taskno=0;
                          var ROW_BASE=1;
                          function addTask()
                          {
                          var oTable=document .getElementById ('myTable');
                          var lastRow = oTable.rows.len gth;
                          var row=oTable.inse rtRow(lastRow);

                          //create WBS Cell
                          oCell = row.insertCell( 0);
                          var el = document.create Element('input' );
                          el.type="text";
                          el.size="5";
                          taskno++;
                          el.value=taskno ;
                          oCell.appendChi ld(el);
                          oCell.innerHTML =oCell.innerHTM L;

                          //Task Name
                          oCell = row.insertCell( 1);
                          var el1 = document.create Element('input' );
                          el1.type="text" ;
                          el1.size="25";
                          oCell.appendChi ld(el1);
                          oCell.innerHTML =oCell.innerHTM L;

                          //Adding SubTask
                          oCell = row.insertCell( 2);
                          var el2 = document.create Element('input' );
                          el2.type="butto n";
                          el2.value="Sub Task";
                          el2.onclick="ad dSubTask(this)" ;
                          oCell.appendChi ld(el2);
                          oCell.innerHTML =oCell.innerHTM L;

                          //Remove Button
                          oCell = row.insertCell( 3);
                          var el3 = document.create Element('input' );
                          el3.type="butto n";
                          el3.value="Remo ve";
                          el3.onclick="re moveThis(this)" ;
                          oCell.appendChi ld(el3);
                          oCell.innerHTML =oCell.innerHTM L;
                          }
                          function addSubTask(rowe l)
                          {
                          var temp;
                          var insert;
                          var subRow = rowel.parentNod e.parentNode;
                          var tbl = subRow.parentNo de.parentNode;
                          var ri = subRow.sectionR owIndex;
                          var nval = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                          var x=ri+1;
                          var nval1;
                          if(ri==(documen t.getElementByI d('myTable').ro ws.length-1))
                          {
                          nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                          }
                          else
                          {
                          nval1 = tbl.tBodies[0].rows[x].cells[0].firstChild.val ue;
                          }
                          var str=nval1+"";
                          flag="TRUE";
                          if(str.indexOf( ".")==-1)
                          {
                          var subtaskno=1;
                          temp =nval+"."+subta skno;
                          insert=ri+1;
                          }
                          else
                          {
                          while(flag=="TR UE")
                          {
                          ri=ri+1;
                          if(ri==(documen t.getElementByI d('myTable').ro ws.length))
                          {
                          nval1 = tbl.tBodies[0].rows[ri-1].cells[0].firstChild.val ue;
                          flag="FALSE";
                          ri=ri-1;
                          str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                          subtaskno=str.s ubstring (str.lastIndexO f (".")+1, str.length);
                          var stask = parseInt(subtas kno);
                          stask=stask+1;
                          temp =nval+"."+stask ;
                          }
                          else
                          {
                          nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                          }
                          var str=nval1+"";
                          if(str.indexOf( ".")==-1)
                          {
                          flag="FALSE";
                          ri=ri-1;
                          str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                          subtaskno=str.s ubstring (str.lastIndexO f (".")+1, str.length);
                          var stask = parseInt(subtas kno);
                          stask=stask+1;
                          temp =nval+"."+stask ;
                          }
                          else
                          {
                          flag=="TRUE" ;
                          }
                          }
                          insert=ri+1;
                          }

                          var oTable=document .getElementById ('myTable');
                          var row=oTable.inse rtRow(insert);

                          //create WBS Cell
                          oCell = row.insertCell( 0);
                          var el = document.create Element('input' );
                          el.type="text";
                          el.size="5";
                          el.value=temp;
                          oCell.appendChi ld(el);
                          oCell.innerHTML =oCell.innerHTM L;

                          //Task Name
                          oCell = row.insertCell( 1);
                          var el1 = document.create Element('input' );
                          el1.type="text" ;
                          el1.size="25";
                          oCell.appendChi ld(el1);
                          oCell.innerHTML =oCell.innerHTM L;

                          //Adding SubTask
                          oCell = row.insertCell( 2);
                          var el2 = document.create Element('input' );
                          el2.type="butto n";
                          el2.value="Temp ";
                          el2.onclick="sh owTemp(this)";
                          oCell.appendChi ld(el2);
                          oCell.innerHTML =oCell.innerHTM L;

                          //Remove Button
                          oCell = row.insertCell( 3);
                          var el3 = document.create Element('input' );
                          el3.type="butto n";
                          el3.value="Remo ve";
                          el3.onclick="re moveThis(this)" ;
                          oCell.appendChi ld(el3);
                          oCell.innerHTML =oCell.innerHTM L;
                          }
                          function showTemp(rowel)
                          {
                          alert("This is temp");
                          }
                          function removeThis(rowe l)
                          {
                          var delRow = rowel.parentNod e.parentNode;
                          var tbl = delRow.parentNo de.parentNode;
                          var rIndex = delRow.sectionR owIndex;
                          var nval = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                          var str=nval;
                          if(str.indexOf( ".")==-1)
                          {
                          document.getEle mentById('myTab le').deleteRow( rIndex);
                          taskno--;
                          var flag="TRUE";
                          while(flag=="TR UE")
                          {
                          if(rIndex<docum ent.getElementB yId('myTable'). rows.length)
                          {
                          var nval = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                          var str=nval;
                          if(str.indexOf( ".")==-1)
                          {
                          flag="FALSE";
                          }
                          else
                          {
                          if(rIndex==docu ment.getElement ById('myTable') .rows.length)
                          {
                          flag=="FALSE";
                          }
                          document.getEle mentById('myTab le').deleteRow( rIndex);
                          }
                          }
                          else
                          {
                          flag="FALSE";
                          }
                          }
                          reorder();
                          }
                          else
                          {
                          document.getEle mentById('myTab le').deleteRow( rIndex);
                          if(rIndex==docu ment.getElement ById('myTable') .rows.length)
                          {
                          flag1=="FALSE";
                          }
                          else
                          {
                          var flag1="TRUE";
                          while(flag1=="T RUE")
                          {
                          if(rIndex==docu ment.getElement ById('myTable') .rows.length)
                          {
                          return;
                          }
                          var x = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                          var y=x+"";
                          if(y.indexOf(". ")==-1)
                          {
                          flag1="false";
                          }
                          else
                          {
                          tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue=nval;
                          nval=y;
                          rIndex= rIndex+1;
                          }

                          }
                          }
                          }
                          }
                          var lastValue;
                          function reorder()
                          {
                          var len=document.ge tElementById('m yTable').rows.l ength;
                          var tbl = document.getEle mentById('myTab le');
                          i=0;
                          tbl.tBodies[0].rows[1].cells[0].firstChild.val ue=1;
                          lastValue=tbl.t Bodies[0].rows[1].cells[0].firstChild.val ue;
                          var taskno=0;
                          i=2;
                          do
                          {
                          var x = tbl.tBodies[0].rows[i].cells[0].firstChild.val ue;
                          var y= x+"";
                          if(y.indexOf(". ")==-1)
                          {
                          lastValue=parse Int(lastValue)+ 1;
                          tbl.tBodies[0].rows[i].cells[0].firstChild.val ue=lastValue;
                          lastValue= tbl.tBodies[0].rows[i].cells[0].firstChild.val ue;
                          taskno=0;
                          }
                          else
                          {
                          taskno=taskno+1 ;
                          var temp = lastValue+"."+t askno;
                          tbl.tBodies[0].rows[i].cells[0].firstChild.val ue=temp;
                          }
                          i=i+1;
                          }
                          while(i<len);

                          }
                          </script>
                          </head>
                          <body>
                          <br/>
                          <input type="button" value="Add Task" onclick="addTas k()">
                          <br/>
                          <table id='myTable'>
                          <tr>
                          <th>WBS</th>
                          <th>Task Name</th>
                          <th></th>
                          <th></th>
                          </tr>
                          </table>
                          </body>
                          </html>[/HTML]

                          From tomorrow I will be trying to add sub sub task in WBS. This code is enough for persons who are looking for creating the Task and Subtask alone in WBS. I am happy sir, Thanks a lot.

                          Regards
                          Ramanan Kalirajan

                          Comment

                          • RamananKalirajan
                            Contributor
                            • Mar 2008
                            • 608

                            #14
                            Completed code for WBS - Work BreakDown Structure

                            Hi guys I had completed the WBS code in Javascript. I had did to my knowledge you all can make use of it. If any changes please post me

                            [HTML]<html>
                            <head>
                            <script language="javas cript">[/html]
                            [code=javascript]var taskno=0;
                            var ROW_BASE=1;
                            function addTask()
                            {
                            var oTable=document .getElementById ('myTable');
                            var lastRow = oTable.rows.len gth;
                            var row=oTable.inse rtRow(lastRow);

                            //create WBS Cell
                            oCell = row.insertCell( 0);
                            var el = document.create Element('input' );
                            el.type="text";
                            el.size="5";
                            taskno++;
                            el.value=taskno ;
                            oCell.appendChi ld(el);
                            oCell.innerHTML =oCell.innerHTM L;

                            //Task Name
                            oCell = row.insertCell( 1);
                            var el1 = document.create Element('input' );
                            el1.type="text" ;
                            el1.size="25";
                            oCell.appendChi ld(el1);
                            oCell.innerHTML =oCell.innerHTM L;

                            //Adding SubTask
                            oCell = row.insertCell( 2);
                            var el2 = document.create Element('input' );
                            el2.type="butto n";
                            el2.value="Sub Task";
                            el2.onclick="ad dSubTask(this)" ;
                            oCell.appendChi ld(el2);
                            oCell.innerHTML =oCell.innerHTM L;

                            //Remove Button
                            oCell = row.insertCell( 3);
                            var el3 = document.create Element('input' );
                            el3.type="butto n";
                            el3.value="Remo ve";
                            el3.onclick="re moveThis(this)" ;
                            oCell.appendChi ld(el3);
                            oCell.innerHTML =oCell.innerHTM L;
                            }
                            function addSubTask(rowe l)
                            {
                            var temp;
                            var insert;
                            var subRow = rowel.parentNod e.parentNode;
                            var tbl = subRow.parentNo de.parentNode;
                            var ri = subRow.sectionR owIndex;
                            var nval = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            var x=ri+1;
                            var nval1;
                            if(ri==(documen t.getElementByI d('myTable').ro ws.length-1))
                            {
                            nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            }
                            else
                            {
                            nval1 = tbl.tBodies[0].rows[x].cells[0].firstChild.val ue;
                            }
                            var str=nval1+"";
                            flag="TRUE";
                            if(str.indexOf( ".")==-1)
                            {
                            var subtaskno=1;
                            temp =nval+"."+subta skno;
                            insert=ri+1;
                            }
                            else
                            {
                            while(flag=="TR UE")
                            {
                            ri=ri+1;
                            if(ri==(documen t.getElementByI d('myTable').ro ws.length))
                            {
                            nval1 = tbl.tBodies[0].rows[ri-1].cells[0].firstChild.val ue;
                            flag="FALSE";
                            ri=ri-1;
                            str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            subtaskno=str.s ubstring (str.lastIndexO f (".")+1, str.length);
                            var stask = parseInt(subtas kno);
                            stask=stask+1;
                            temp =nval+"."+stask ;
                            }
                            else
                            {
                            nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            }
                            var str=nval1+"";
                            if(str.indexOf( ".")==-1)
                            {
                            flag="FALSE";
                            ri=ri-1;
                            str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            subtaskno=str.s ubstring (str.lastIndexO f (".")+1, str.length);
                            var stask = parseInt(subtas kno);
                            stask=stask+1;
                            temp =nval+"."+stask ;
                            }
                            else
                            {
                            flag=="TRUE" ;
                            }
                            }
                            insert=ri+1;
                            }

                            var oTable=document .getElementById ('myTable');
                            var row=oTable.inse rtRow(insert);

                            //create WBS Cell
                            oCell = row.insertCell( 0);
                            var el = document.create Element('input' );
                            el.type="text";
                            el.size="5";
                            el.value=temp;
                            oCell.appendChi ld(el);
                            oCell.innerHTML =oCell.innerHTM L;

                            //Task Name
                            oCell = row.insertCell( 1);
                            var el1 = document.create Element('input' );
                            el1.type="text" ;
                            el1.size="25";
                            oCell.appendChi ld(el1);
                            oCell.innerHTML =oCell.innerHTM L;

                            //Adding SubSubTask
                            oCell = row.insertCell( 2);
                            var el2 = document.create Element('input' );
                            el2.type="butto n";
                            el2.value="Sub Sub Task";
                            el2.onclick="cr eateSubSubTask( this)";
                            oCell.appendChi ld(el2);
                            oCell.innerHTML =oCell.innerHTM L;

                            //Remove Button
                            oCell = row.insertCell( 3);
                            var el3 = document.create Element('input' );
                            el3.type="butto n";
                            el3.value="Remo ve";
                            el3.onclick="re moveThis(this)" ;
                            oCell.appendChi ld(el3);
                            oCell.innerHTML =oCell.innerHTM L;
                            }[/code]

                            [code=javascript]// Function for creating Sub Sub Task

                            function createSubSubTas k(rowel)
                            {
                            var temp;
                            var insert;
                            var subRow = rowel.parentNod e.parentNode;
                            var tbl = subRow.parentNo de.parentNode;
                            var ri = subRow.sectionR owIndex;
                            var nval = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            var x=ri+1;
                            var nval1;
                            if(ri==(documen t.getElementByI d('myTable').ro ws.length-1))
                            {
                            nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            }
                            else
                            {
                            nval1 = tbl.tBodies[0].rows[x].cells[0].firstChild.val ue;
                            }
                            var str=nval1+"";
                            flag="TRUE";
                            if(str.lastInde xOf(".")==1)
                            {
                            var subsubtaskno=1;
                            temp =nval+"."+subsu btaskno;
                            insert=ri+1;
                            }
                            else
                            {
                            if(str.lastInde xOf(".")==-1)
                            {
                            subsubtaskno=1;
                            temp =nval+"."+subsu btaskno;
                            insert=ri+1;
                            }
                            else
                            {
                            while(flag=="TR UE")
                            {
                            ri=ri+1;
                            if(ri==(documen t.getElementByI d('myTable').ro ws.length))
                            {
                            flag="FALSE";
                            }
                            else
                            {
                            var check=tbl.tBodi es[0].rows[ri].cells[0].firstChild.val ue
                            str = check+"";
                            if(str.lastInde xOf(".")==-1)
                            {
                            nval1 = tbl.tBodies[0].rows[ri-1].cells[0].firstChild.val ue;
                            flag="FALSE";
                            ri=ri-1;
                            str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            subsubtaskno=st r.substring (str.lastIndexO f (".")+1, str.length);
                            var stask = parseInt(subsub taskno);
                            stask=stask+1;
                            temp =nval+"."+stask ;
                            }
                            else
                            {
                            flag="TRUE";
                            }
                            }
                            if(ri==(documen t.getElementByI d('myTable').ro ws.length))
                            {
                            nval1 = tbl.tBodies[0].rows[ri-1].cells[0].firstChild.val ue;
                            flag="FALSE";
                            ri=ri-1;
                            str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            subsubtaskno=st r.substring (str.lastIndexO f (".")+1, str.length);
                            var stask = parseInt(subsub taskno);
                            stask=stask+1;
                            temp =nval+"."+stask ;
                            }
                            else
                            {
                            nval1 = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            }
                            var str=nval1+"";
                            if(str.lastInde xOf(".")==1)
                            {
                            flag="FALSE";
                            ri=ri-1;
                            str = tbl.tBodies[0].rows[ri].cells[0].firstChild.val ue;
                            subsubtaskno=st r.substring (str.lastIndexO f (".")+1, str.length);
                            var stask = parseInt(subsub taskno);
                            stask=stask+1;
                            temp =nval+"."+stask ;
                            }
                            else
                            {
                            flag=="TRUE" ;
                            }
                            }
                            }
                            insert=ri+1;
                            }

                            var oTable=document .getElementById ('myTable');
                            var row=oTable.inse rtRow(insert);

                            //create WBS Cell
                            oCell = row.insertCell( 0);
                            var el = document.create Element('input' );
                            el.type="text";
                            el.size="5";
                            el.value=temp;
                            oCell.appendChi ld(el);
                            oCell.innerHTML =oCell.innerHTM L;

                            //Task Name
                            oCell = row.insertCell( 1);
                            var el1 = document.create Element('input' );
                            el1.type="text" ;
                            el1.size="25";
                            oCell.appendChi ld(el1);
                            oCell.innerHTML =oCell.innerHTM L;

                            //Adding SubTask
                            oCell = row.insertCell( 2);
                            var el2 = document.create Element('nbsp') ;
                            oCell.appendChi ld(el2);
                            oCell.innerHTML =oCell.innerHTM L;

                            //Remove Button
                            oCell = row.insertCell( 3);
                            var el3 = document.create Element('input' );
                            el3.type="butto n";
                            el3.value="Remo ve";
                            el3.onclick="re moveThis(this)" ;
                            oCell.appendChi ld(el3);
                            oCell.innerHTML =oCell.innerHTM L;
                            }

                            // End of Sub Sub Task Creation

                            function removeThis(rowe l)
                            {
                            var delRow = rowel.parentNod e.parentNode;
                            var tbl = delRow.parentNo de.parentNode;
                            var rIndex = delRow.sectionR owIndex;
                            var nval = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                            var str=nval;
                            if(str.indexOf( ".")==-1)
                            {
                            document.getEle mentById('myTab le').deleteRow( rIndex);
                            taskno--;
                            var flag="TRUE";
                            while(flag=="TR UE")
                            {
                            if(rIndex<docum ent.getElementB yId('myTable'). rows.length)
                            {
                            var nval = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                            var str=nval;
                            if(str.indexOf( ".")==-1)
                            {
                            flag="FALSE";
                            }
                            else
                            {
                            if(rIndex==docu ment.getElement ById('myTable') .rows.length)
                            {
                            flag=="FALSE";
                            }
                            document.getEle mentById('myTab le').deleteRow( rIndex);
                            }
                            }
                            else
                            {
                            flag="FALSE";
                            }
                            }
                            reorder();
                            }
                            else if(str.lastInde xOf(".")==1)
                            {
                            document.getEle mentById('myTab le').deleteRow( rIndex);
                            var flag="TRUE";
                            while(flag=="TR UE")
                            {
                            if(rIndex<docum ent.getElementB yId('myTable'). rows.length)
                            {
                            var nval = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                            var str=nval;
                            if(str.lastInde xOf(".")==1)
                            {
                            flag="FALSE";
                            }
                            else
                            {
                            if(rIndex==docu ment.getElement ById('myTable') .rows.length)
                            {
                            flag=="FALSE";
                            }
                            document.getEle mentById('myTab le').deleteRow( rIndex);
                            }
                            }
                            else
                            {
                            flag="FALSE";
                            }
                            }
                            reorder();
                            }
                            else
                            {
                            document.getEle mentById('myTab le').deleteRow( rIndex);
                            if(rIndex==docu ment.getElement ById('myTable') .rows.length)
                            {
                            flag1=="FALSE";
                            }
                            else
                            {
                            var flag1="TRUE";
                            while(flag1=="T RUE")
                            {
                            if(rIndex==docu ment.getElement ById('myTable') .rows.length)
                            {
                            return;
                            }
                            var x = tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue;
                            var y=x+"";
                            if(y.lastIndexO f(".")==1)
                            {
                            flag1="false";
                            }
                            else
                            {
                            tbl.tBodies[0].rows[rIndex].cells[0].firstChild.val ue=nval;
                            nval=y;
                            rIndex= rIndex+1;
                            }
                            }
                            }
                            reorder();
                            }
                            }[/code]
                            [code=javascript]var lastValue;
                            function reorder()
                            {
                            var len=document.ge tElementById('m yTable').rows.l ength;
                            var tbl = document.getEle mentById('myTab le');
                            i=0;
                            if(len>1)
                            {
                            tbl.tBodies[0].rows[1].cells[0].firstChild.val ue=1;
                            lastValue=tbl.t Bodies[0].rows[1].cells[0].firstChild.val ue;
                            }
                            var taskno=0;
                            var staskno=0;
                            var subtaskno=0;
                            i=2;
                            while(i<len)
                            {
                            var x = tbl.tBodies[0].rows[i].cells[0].firstChild.val ue;
                            var y= x+"";
                            if(y.indexOf(". ")==-1)
                            {
                            lastValue=parse Int(lastValue)+ 1;
                            tbl.tBodies[0].rows[i].cells[0].firstChild.val ue=lastValue;
                            lastValue= tbl.tBodies[0].rows[i].cells[0].firstChild.val ue;
                            taskno=0;
                            }
                            else if(y.lastIndexO f(".")==1)
                            {
                            taskno=taskno+1 ;
                            var staskno = lastValue+"."+t askno;
                            tbl.tBodies[0].rows[i].cells[0].firstChild.val ue=staskno;
                            subtaskno=0;
                            }
                            else
                            {
                            subtaskno=subta skno+1;
                            var temp = staskno+"."+sub taskno;
                            tbl.tBodies[0].rows[i].cells[0].firstChild.val ue=temp;
                            }
                            i=i+1;
                            }

                            }[/code]
                            [html]</script>
                            </head>
                            <body>
                            <br/>
                            <input type="button" value="Add Task" onclick="addTas k()">
                            <br/>
                            <table id='myTable'>
                            <tr>
                            <th>WBS</th>
                            <th>Task Name</th>
                            <th></th>
                            <th></th>
                            </tr>
                            </table>
                            </body>
                            </html>[/HTML]

                            Regards
                            Ramanan Kalirajan
                            Last edited by acoder; Mar 18 '08, 10:21 AM.

                            Comment

                            • acoder
                              Recognized Expert MVP
                              • Nov 2006
                              • 16032

                              #15
                              I've merged your threads. Just one quick point: the language attribute of the script tag is deprecated, use type="text/javascript" instead.

                              Comment

                              Working...