You must Sign In to post a response.
• # Manipulating table cells

I'm busy with a school assignment. I have to create a table, then enter numbers into all the cells of the table. Then i have to get the lowest value in each row, then deduct the value from each of the values in that row. Then i have to get the lowest value in each column of the table and then deduct that value from each value in that column. Then I will have three lines of two or more zeros in a line, for a table that has 3 column and rows.

e.g.

Table 1, this is the table I will get after creating it dynamically and entering values in each cell.
c1 c2 c3
r1 [11] [14] [6]
r2 [8] [10] [11]
r3 [9] [12] [7]

(we have to deduct the lowest value in each row value)

Table 2 (this is the table i get after deducting the lowest value from each row cell)

c1 c2 c3
r1 [5] [8] [0]
r2 [0] [2] [3]
r3 [2] [5] [0]

(we have to deduct the lowest value in each column value)

Table 3 (this is the table i get after deducting the lowest value from each column cell)

c1 c2 c3
r1 [5] [6] [0]
r2 [0] [0] [3]
r3 [2] [3] [0]

Then we start looking for the three(3) lines of two or more zeros. Cause we have 3 columns and rows
c1 c2 | c3
r1 [5] [6] [| (0)]
r2 [-(0)] [- (0)] [| (3)]--
r3 [2] [3] [| (0)]
cause we are only getting two lines of two or more zeros. we have to get the lowest value in the whole table that does not have 2 or more zeros. Then deduct it from all the cell values of the table that are not zero and add it to the number where the lines intersect. Which is two in this case and the number where the two lines intersect is 3.

Table 4

Two is the lowest in this case:
c1 c2 c3
r1 [3] [4] [|0]
r2 [0-] [-0] [-|5]--
r3 [0-] [-1] [-|0]--
Now that we have three lines in a table of 3 columns and 3 rows we are done. we can print the final table.
• PinkyPonky PonkyPinky
PinkyPinky PonkyPonky
PonkyPonky PinkyPinky
PonkyPinky PinkyPonky

this is what you are explain about your requirement... I didn't understand anything why you are deduct the minimum value from 1st row? again why you are deduct minimum value from column wise? again you are doing some other deductions...

It's totally confused, please elaborate the requirement and give some simple example to understand easily then only we can help you.

Once people understand the question then only they try to help you based on their experience, without understand the question you can't expect answer from others.

Please read the forum policies while raise a question...

--------------------------------------------------------------------------------
Give respect to your work, Instead of trying to impress your boss.

N@veen
Blog : http://naveens-dotnet.blogspot.in/

• You can use this code snippet to Manipulating table cells`<table id="tbl" border="1" runat="server" > <tr id="row1"> <td> </td> <td> </td> <td> </td> </tr> <tr id="row2"> <td rowspan="3">**</td> <td>AAAA</td> <td> </td> </tr> <tr id="row3"> <td>BBBB</td> <td> </td> </tr> </table><script type="text/javascript">var trs = document.getElementById("tbl").getElementsByTagName("tr");var tds;var bDeleted = false;var currRowToDelete = 3;for(var i=0;i<currRowToDelete;i++){ tds = trs[i].getElementsByTagName('td'); for(var j=0;j<tds.length;j++) { var currRowSpan = tds[j].rowSpan; if(currRowSpan > 1) { if(eval(i + 1) == currRowToDelete) { var cell = document.createElement("td"); cell.innerHTML = tds[j].innerHTML; trs[i + 1].insertBefore(cell, trs[i + 1].getElementsByTagName('td')[0]); document.getElementById("tbl").deleteRow(i); bDeleted = true; document.getElementById("tbl").rows[i].cells[0].rowSpan = eval(currRowSpan -1); } else { if(eval(currRowSpan + i) >= currRowToDelete) document.getElementById("tbl").rows[i].cells[0].rowSpan = eval(currRowSpan -1); } } }}if(bDeleted == false) document.getElementById("tbl").deleteRow(currRowToDelete -1);</script>`

• Hai Stanley,
I thin you can create a multi dimensional array and store each of the row and column values to the array. Once you store the values in to the array, you can do the manipulations by iteration for each row and column to get the desired result.
Hope it will be helpful to you.

Regards,
Pawan Awasthi(DNS MVM)
+91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
pawansoftit@gmail.com

• Sign In to post your comments