Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

deleting row problem

hi
I am trying to create arow dynamically.
I could do it wothout eror.
Assume that i added 3 rows.now if i check the checkbox of second row and click delete ,it is successful .after that i tried the next row it is giving error.
Please help
<html>

<head>

<title>Effort Search</title>

<script language="JavaScript">

function setActivity()
{
      var actval
      //actval = document.esas.activity.value
      //document.esrfs.hact.value = actval
      //document.esrfs.hactbool.value = "1"      
}
var check
check =0
var check1
check1 =0

function clickDelete()
{
      var count;
      count = document.esas.hidID.value;
      for (var i = 1; i <= count; i++)
      {
            if (eval("document.esas.hidRow"+i+".checked") == false)
                  check = 1;
            else
                  check1 = 2;
            
      }
            
      if (check1 != 2)
      {
            
            alert("select check box");
            return false;
      }
      else
      {
            for (var i = 1; i <= count; i++)
            {
                  if (eval("document.esas.hidRow"+i+".checked") == true)
                  {
            
                        tab1.deleteRow(i);
                        document.esas.hidID.value = document.esas.hidID.value - 1
                  }
            }
            alert(document.esas.hidID.value);
            
            
      }
}

function clearcomboact(no)
{
var obj
obj=eval("document.esas.activity"+no)
      for (var i = obj.options.length-1;i>=0;i--)
      {
            obj.options[i] = null
      }
      
      obj.selectedIndex = -1;
}


function PhaseList()
{
for(var i=0;i<obj.length;i++)
      {
            document.esas.activity.options[document.esas.activity.options.length] = new Option(obj[i][1],obj[i][0]);            
      }
}

function clickAdd()
{
      document.esas.hidAdd.value = parseInt(document.esas.hidAdd.value) + 1;
      document.esas.method       = "post";
      document.esas.action       = "dynamic linked select box from database1.asp";
      document.esas.submit();
}

function clickSave()
{
      document.esas.hidAct.value = "save"
      document.esas.method       = "post";
      document.esas.action       = "dynamic linked select box from database1.asp";
      document.esas.submit();
}




var newID=1
function add1()
{

      var act
      var phase
      phase=""
      act1=""

      objAdd = tab1.insertRow(tab1.rows.length);
      objAdd.insertCell(0);
      objAdd.insertCell(1);
      objAdd.insertCell(2);
      newinput1 = document.createElement("<SELECT name = activity"+ newID+">");
      //newinput1.name = "activity"+ newID+'';
      newinput1.ID = "act"+ newID+'';
      actName=  "activity"+ newID+'';
      
      objAdd.cells.item(1).appendChild(newinput1);
      
      newinput0 = document.createElement("<SELECT name = phase"+ newID+" onchange=phaseselect1(this,newinput2,act1,actName)>");
      //newinput0.name = "phase"+ newID+'';
      newinput0.options[newinput0.options.length] =  new Option('All Phases','',true,true);
      //newinput0.options[newinput0.options.length] = new Option("HI","HI1",false,true);
      for(var i=0;i<phaseArray.length;i++)
            {
                  if (phase==phaseArray[i][0])
                  {
                  newinput0.options[newinput0.options.length] = new Option(phaseArray[i][1],phaseArray[i][0],false,true);            
                  }
                  else
                  {
                  newinput0.options[newinput0.options.length] = new Option(phaseArray[i][1],phaseArray[i][0]);            
                  }
            }      
      objAdd.cells.item(0).appendChild(newinput0);
      
      newinput2 = document.createElement("<input type=checkbox name = hidRow"+ newID+">");
      newinput2.name = "hidRow"+ newID+'';
      //newinput2.value = newID;
      objAdd.cells.item(2).appendChild(newinput2);
      
      //phaseselect1(newinput0,newID,act,newinput1)
      newinput1.options[newinput1.options.length] =  new Option('All Activities','',true,true);
      
      document.esas.hidID.value = newID      
      
      
      newID=newID+1
      }
      
      function phaseselect1(elem,no,act,objName)
      {
      //clearcomboact(no);
      var objact
      phaseName = elem.name
      phaseName = phaseName.substring(5,phaseName.length)
      str = "activity"+phaseName
      for (var i = 0; i < document.esas.elements.length; i++)
            {
                  if (document.esas.elements[i].name==str)
                  {
                  objact = document.esas.elements[i]
                  }
                        
            }
      for (var i = objact.options.length-1;i>=0;i--)
      {
            objact.options[i] = null
      }
      
      
      objact.options[objact.options.length] =  new Option('All Activities','',true,true);
      
      if (elem.options[elem.selectedIndex].value!="" )
      {
            obj1 =eval("arr"+elem.options[elem.selectedIndex].value)
            for(var i=0;i<obj1.length;i++)
            {
                  if (act==obj1[i][0])
                  {
                  
                  objact.options[objact.options.length] = new Option(obj1[i][1],obj1[i][0],false,true);            
                  }
                  else
                  {
                  objact.options[objact.options.length] = new Option(obj1[i][1],obj1[i][0]);            
                  }
            }
      }

}



</script>

</head>

<script language=javascript>var phaseArray=[['adm','Administration']];

 var arradm=[['adm016','Arranging Meetings'],['adm008','Attendance System']];
 </script>
 

<body>
<form name="esas" action="pradeepaSub.asp" method=post>

            <table border="1" width="100%" id=tab1>
                  <tr>
                        <td  bgcolor = "#d6d6ab">
                              <label >Phase</label>
                        </td>
                  
                        <td width="41%"   bgcolor = "e8e8d2">
                              <label><label>Activity</label>
                              
                        </td>
                  </tr>
      
      
            </table>
            <br>
            
            <div align='center'>
            <input type=button name=add onclick="add1()" value="Add">
            <input type=button name=butDel onclick="clickDelete()"  value="Delete">                  
            <input type="submit" value="Save" name="addSave" >
            <input type="hidden" name="hidID">      
                  
            </div>
            
</form>      

</body>
</html>

0
pr_r
Asked:
pr_r
1 Solution
 
pr_rAuthor Commented:
hi
Please move this to javascript section
0
 
pr_rAuthor Commented:
hi
Please move this to javascript section
0
 
avnerCommented:
pr_r , did you try my fix ?

<html>

<head>

<title>Effort Search</title>

<script language="JavaScript">

function setActivity()
{
   var actval
   //actval = document.esas.activity.value
   //document.esrfs.hact.value = actval
   //document.esrfs.hactbool.value = "1"      
}
var check
check =0
var check1
check1 =0

function clickDelete()
{
     var check1 = null;
     var oTable = document.getElementById("tab1");
     var iCount =  oTable.rows.length-1;
   for (var i = 0; i < iCount; i++)
   {
     var oCheckBox = oTable.rows[i+1].cells[2].firstChild;
     if (oCheckBox.checked)
          {
               check1 = i;
               break;
          }
   }
       
   if (check1 == null)
   {
       
        alert("select check box");
        return false;
   }
   else
   {

        for (var i = 0; i < iCount; i++)
        {
                var oCheckBox = oTable.rows[i+1].cells[2].firstChild;
               if (oCheckBox.checked)
                    {
                       tab1.deleteRow(i+1);
                  document.esas.hidID.value = parseInt(document.esas.hidID.value)- 1;
                         iCount--;
                         i--;
             }
        }
       
       
   }
}

function clearcomboact(no)
{
var obj
obj=eval("document.esas.activity"+no)
   for (var i = obj.options.length-1;i>=0;i--)
   {
        obj.options[i] = null
   }
   
   obj.selectedIndex = -1;
}


function PhaseList()
{
for(var i=0;i<obj.length;i++)
   {
        document.esas.activity.options[document.esas.activity.options.length] = new Option(obj[i][1],obj[i][0]);          
   }
}

function clickAdd()
{
   document.esas.hidAdd.value = parseInt(document.esas.hidAdd.value) + 1;
   document.esas.method       = "post";
   document.esas.action       = "dynamic linked select box from database1.asp";
   document.esas.submit();
}

function clickSave()
{
   document.esas.hidAct.value = "save"
   document.esas.method       = "post";
   document.esas.action       = "dynamic linked select box from database1.asp";
   document.esas.submit();
}




var newID=1
function add1()
{

   var act
   var phase
   phase=""
   act1=""

   objAdd = tab1.insertRow(tab1.rows.length);
   objAdd.insertCell(0);
   objAdd.insertCell(1);
   objAdd.insertCell(2);
   newinput1 = document.createElement("<SELECT name = activity"+ newID+">");
   //newinput1.name = "activity"+ newID+'';
   newinput1.ID = "act"+ newID+'';
   actName=  "activity"+ newID+'';
   
   objAdd.cells.item(1).appendChild(newinput1);
   
   newinput0 = document.createElement("<SELECT name = phase"+ newID+" onchange=phaseselect1(this,newinput2,act1,actName)>");
   //newinput0.name = "phase"+ newID+'';
   newinput0.options[newinput0.options.length] =  new Option('All Phases','',true,true);
   //newinput0.options[newinput0.options.length] = new Option("HI","HI1",false,true);
   for(var i=0;i<phaseArray.length;i++)
        {
             if (phase==phaseArray[i][0])
             {
             newinput0.options[newinput0.options.length] = new Option(phaseArray[i][1],phaseArray[i][0],false,true);          
             }
             else
             {
             newinput0.options[newinput0.options.length] = new Option(phaseArray[i][1],phaseArray[i][0]);          
             }
        }    
   objAdd.cells.item(0).appendChild(newinput0);
   
   newinput2 = document.createElement("<input type=checkbox name = hidRow"+ newID+">");
   newinput2.name = "hidRow"+ newID+'';
   //newinput2.value = newID;
   objAdd.cells.item(2).appendChild(newinput2);
   
   //phaseselect1(newinput0,newID,act,newinput1)
   newinput1.options[newinput1.options.length] =  new Option('All Activities','',true,true);
   
   document.esas.hidID.value = newID    
   
   
   newID=newID+1
   }
   
   function phaseselect1(elem,no,act,objName)
   {
   //clearcomboact(no);
   var objact
   phaseName = elem.name
   phaseName = phaseName.substring(5,phaseName.length)
   str = "activity"+phaseName
   for (var i = 0; i < document.esas.elements.length; i++)
        {
             if (document.esas.elements[i].name==str)
             {
             objact = document.esas.elements[i]
             }
                 
        }
   for (var i = objact.options.length-1;i>=0;i--)
   {
        objact.options[i] = null
   }
   
   
   objact.options[objact.options.length] =  new Option('All Activities','',true,true);
   
   if (elem.options[elem.selectedIndex].value!="" )
   {
        obj1 =eval("arr"+elem.options[elem.selectedIndex].value)
        for(var i=0;i<obj1.length;i++)
        {
             if (act==obj1[i][0])
             {
             
             objact.options[objact.options.length] = new Option(obj1[i][1],obj1[i][0],false,true);          
             }
             else
             {
             objact.options[objact.options.length] = new Option(obj1[i][1],obj1[i][0]);          
             }
        }
   }

}



</script>

</head>

<script language=javascript>var phaseArray=[['adm','Administration']];

var arradm=[['adm016','Arranging Meetings'],['adm008','Attendance System']];
</script>


<body>
<form name="esas" action="pradeepaSub.asp" method=post>

        <table border="1" width="100%" id=tab1>
             <tr>
                  <td  bgcolor = "#d6d6ab">
                       <label >Phase</label>
                  </td>
             
                  <td width="41%"   bgcolor = "e8e8d2">
                       <label><label>Activity</label>
                       
                  </td>
             </tr>
   
   
        </table>
        <br>
       
        <div align='center'>
        <input type=button name=add onclick="add1()" value="Add">
        <input type=button name=butDel onclick="clickDelete()"  value="Delete">              
        <input type="submit" value="Save" name="addSave" >
        <input type="hidden" name="hidID">    
             
        </div>
       
</form>    

</body>
</html>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
pr_rAuthor Commented:
hi it is not working in ie5.0
it is giving doctor watson error
0
 
pr_rAuthor Commented:
hi it is not working in ie5.0
it is giving doctor watson error
0
 
avnerCommented:
It might be a problem with your NT, otherwise try this approach :

<html>

<head>

<title>Effort Search</title>

<script language="JavaScript">

function setActivity()
{
  var actval
  //actval = document.esas.activity.value
  //document.esrfs.hact.value = actval
  //document.esrfs.hactbool.value = "1"      
}
var check
check =0
var check1
check1 =0

function clickDelete()
{
    var check1 = null;
    var oTable = document.getElementById("tab1");
    var iCount =  oTable.rows.length-1;
  for (var i = 0; i < iCount; i++)
  {
    var oCheckBox = oTable.rows[i+1].cells[2].firstChild;
    if (oCheckBox.checked)
         {
              check1 = i;
              break;
         }
  }
       
  if (check1 == null)
  {
       
       alert("select check box");
       return false;
  }
  else
  {

       for (var i = 0; i < iCount; i++)
       {
               var oCheckBox = oTable.rows[i+1].cells[2].firstChild;
              if (oCheckBox.checked)
                   {
                      tab1.rows[i+1].parentElement.removeChild(tab1.rows[i+1]);
                 document.esas.hidID.value = parseInt(document.esas.hidID.value)- 1;
                        iCount--;
                        i--;
            }
       }
       
       
  }
}

function clearcomboact(no)
{
var obj
obj=eval("document.esas.activity"+no)
  for (var i = obj.options.length-1;i>=0;i--)
  {
       obj.options[i] = null
  }
 
  obj.selectedIndex = -1;
}


function PhaseList()
{
for(var i=0;i<obj.length;i++)
  {
       document.esas.activity.options[document.esas.activity.options.length] = new Option(obj[i][1],obj[i][0]);          
  }
}

function clickAdd()
{
  document.esas.hidAdd.value = parseInt(document.esas.hidAdd.value) + 1;
  document.esas.method       = "post";
  document.esas.action       = "dynamic linked select box from database1.asp";
  document.esas.submit();
}

function clickSave()
{
  document.esas.hidAct.value = "save"
  document.esas.method       = "post";
  document.esas.action       = "dynamic linked select box from database1.asp";
  document.esas.submit();
}




var newID=1
function add1()
{

  var act
  var phase
  phase=""
  act1=""

  objAdd = tab1.insertRow(tab1.rows.length);
  objAdd.insertCell(0);
  objAdd.insertCell(1);
  objAdd.insertCell(2);
  newinput1 = document.createElement("<SELECT name = activity"+ newID+">");
  //newinput1.name = "activity"+ newID+'';
  newinput1.ID = "act"+ newID+'';
  actName=  "activity"+ newID+'';
 
  objAdd.cells.item(1).appendChild(newinput1);
 
  newinput0 = document.createElement("<SELECT name = phase"+ newID+" onchange=phaseselect1(this,newinput2,act1,actName)>");
  //newinput0.name = "phase"+ newID+'';
  newinput0.options[newinput0.options.length] =  new Option('All Phases','',true,true);
  //newinput0.options[newinput0.options.length] = new Option("HI","HI1",false,true);
  for(var i=0;i<phaseArray.length;i++)
       {
            if (phase==phaseArray[i][0])
            {
            newinput0.options[newinput0.options.length] = new Option(phaseArray[i][1],phaseArray[i][0],false,true);          
            }
            else
            {
            newinput0.options[newinput0.options.length] = new Option(phaseArray[i][1],phaseArray[i][0]);          
            }
       }    
  objAdd.cells.item(0).appendChild(newinput0);
 
  newinput2 = document.createElement("<input type=checkbox name = hidRow"+ newID+">");
  newinput2.name = "hidRow"+ newID+'';
  //newinput2.value = newID;
  objAdd.cells.item(2).appendChild(newinput2);
 
  //phaseselect1(newinput0,newID,act,newinput1)
  newinput1.options[newinput1.options.length] =  new Option('All Activities','',true,true);
 
  document.esas.hidID.value = newID    
 
 
  newID=newID+1
  }
 
  function phaseselect1(elem,no,act,objName)
  {
  //clearcomboact(no);
  var objact
  phaseName = elem.name
  phaseName = phaseName.substring(5,phaseName.length)
  str = "activity"+phaseName
  for (var i = 0; i < document.esas.elements.length; i++)
       {
            if (document.esas.elements[i].name==str)
            {
            objact = document.esas.elements[i]
            }
                 
       }
  for (var i = objact.options.length-1;i>=0;i--)
  {
       objact.options[i] = null
  }
 
 
  objact.options[objact.options.length] =  new Option('All Activities','',true,true);
 
  if (elem.options[elem.selectedIndex].value!="" )
  {
       obj1 =eval("arr"+elem.options[elem.selectedIndex].value)
       for(var i=0;i<obj1.length;i++)
       {
            if (act==obj1[i][0])
            {
           
            objact.options[objact.options.length] = new Option(obj1[i][1],obj1[i][0],false,true);          
            }
            else
            {
            objact.options[objact.options.length] = new Option(obj1[i][1],obj1[i][0]);          
            }
       }
  }

}



</script>

</head>

<script language=javascript>var phaseArray=[['adm','Administration']];

var arradm=[['adm016','Arranging Meetings'],['adm008','Attendance System']];
</script>


<body>
<form name="esas" action="pradeepaSub.asp" method=post>

       <table border="1" width="100%" id=tab1>
            <tr>
                 <td  bgcolor = "#d6d6ab">
                      <label >Phase</label>
                 </td>
           
                 <td width="41%"   bgcolor = "e8e8d2">
                      <label><label>Activity</label>
                     
                 </td>
            </tr>
 
 
       </table>
       <br>
       
       <div align='center'>
       <input type=button name=add onclick="add1()" value="Add">
       <input type=button name=butDel onclick="clickDelete()"  value="Delete">              
       <input type="submit" value="Save" name="addSave" >
       <input type="hidden" name="hidID">    
           
       </div>
       
</form>    

</body>
</html>
0
 
COBOLdinosaurCommented:
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

<note>
Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>

If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp


Cd&

0
 
Programming_GalCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept avner's comment as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Programming_Gal
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now