?
Solved

deleting row problem

Posted on 2003-03-13
8
Medium Priority
?
263 Views
Last Modified: 2012-05-04
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
Comment
Question by:pr_r
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 2

Author Comment

by:pr_r
ID: 8126303
hi
Please move this to javascript section
0
 
LVL 2

Author Comment

by:pr_r
ID: 8126741
hi
Please move this to javascript section
0
 
LVL 14

Expert Comment

by:avner
ID: 8126917
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:pr_r
ID: 8164336
hi it is not working in ie5.0
it is giving doctor watson error
0
 
LVL 2

Author Comment

by:pr_r
ID: 8164351
hi it is not working in ie5.0
it is giving doctor watson error
0
 
LVL 14

Accepted Solution

by:
avner earned 600 total points
ID: 8164668
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 9115238
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
 
LVL 6

Expert Comment

by:Programming_Gal
ID: 9648687
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question