Ok. after opening a brace before the if statement and taking out the else statement thanks to
pactor21 at webdeveloper.com, I got the first inserted row and last inserted row containing cells of className 'rowsubtotal' innerHTML to match the innerHTM of cell id 'subtotal' in the table but any rows in between row index 0 and row index -1 or last are unchanged.
The script
Code:
function checksubtotal(){
var subtotal=document.getElementById('subtotal').innerHTML;
var rowsubtotals=document.getElementsByClassName('rowsubtotal');
for(var i=0; i< rowsubtotals.length; i++){ //loop only gets first and last
var rowsubtotal=rowsubtotals[i];
}
if(rowsubtotal.innerHTML!==subtotal){ // may need comparison '!match subtotal' ?
rowsubtotal.innerHTML=subtotal;
}
}
function deleterow(a) {
// remove row
var rowsubtotals=document.getElementsByClassName('rowsubtotal');
var row=a.parentNode.parentNode;
row.parentNode.removeChild(row);
var sTotal=sumsubtotal();
checksubtotal();//only changes first and last rows cells className 'rowsubtotal' ?
EvalSound4();
}
HTML RESULT
HTML Code:
<tfoot>
<tr id="footsubtotal">
<td id="subtotal">$ 75.00</td>
//all cells of class "rowsubtotal" must have same innerHTML as this.
</tr>
</tfoot>
<tbody>
<tr class="itemrow"><td class="rowsubtotal">$ 75.00</td></tr>
<!--3rd inserted row at row index 0 innerHTML equals '$ 75.00' or innerHTML of 'subtotal'-->
<tr class="itemrow"><td class="rowsubtotal">$ 20.00</td></tr>
<!--2nd inserted row at row index 0 innerHTML should be '$ 75.00' but doesn't ?-->
<tr class="itemrow"><td class="rowsubtotal">$ 75.00</td></tr>
<!--1st inserted row at row index 0 innerHTML equals '$ 75.00' or innerHTML of 'subtotal'-->
<tr class="dumy"><td class="message">Thank You</td></tr>
</tbody>
I'm realy thinking a comparison by match of the innerHTML of 'subtotal' might get the for loop getting all the cells of className 'rowsubtotal' to equal cell id 'subtotal' innerTML. Will check it out.
pactor21 any ideas on matching the innerHTML?
Bookmarks