[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Javascript Delete Row Problem

Asked by johnny_32 in Document Object Model, JavaScript

I have a dynamic table with tr ids set as below as an example.
<Table name = "tblGrid">
<tr id=1>
    <Td></td>
</tr>
<tr id=2>
    <Td></td>
</tr>
<tr id=3>
    <Td></td>
</tr>
<tr id=4>
    <Td></td>
</tr>
</table>

I then have a array which determines which row ids need deleting  eg (1,2,3)

In order to do this i loop through the table rows. If the table row matches the array item to be deleted it is deleted. The problem is the table rows go out of synch once it  is deleted.

For example :
Looping through array(1,2,3)
Array item 1

TR 1       ArrayItem(1)        TR1 equals ArrayItem(1)   so delete Row 1
TR 2
TR 3
TR 4

Array item 2  I want to delete TR(2) but the loop now counts to TR3 as this is the 2nd item in the loop

TR 2      
TR 3
TR 4
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
In example here table has 4 TRs as above 
 
 
var flr = document.getElementById('tblGrid');
                var  count = flr.rows.length;
                            for (var i = 0; i < count; i++) {
                  
                                for (iTem = 0; iTem < loopIds.length; iTem++) {
 
                                    if (i > 0 ) { // dont want table header row
                                             if (loopIds[iTem] == i) {
                                            var flr2 = document.getElementById('tblGrid');
                                            IDval = parseInt(flr.rows[i].id, 0);
                                                                              
                                            document.all.tblGrid.deleteRow(IDval);
                                         }
                                     }
                                 }
                                
                                
                         }
 
Loading Advertisement...
 
[+][-]03/16/09 06:11 AM, ID: 23897260Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/16/09 06:33 AM, ID: 23897478Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/17/09 02:36 PM, ID: 23913437Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/18/09 10:29 AM, ID: 23921222Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Document Object Model, JavaScript
Sign Up Now!
Solution Provided By: johnny_32
Participating Experts: 3
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625