I’m trying to grab all the cells created with insertrow function and the className ‘rowtotal’ and get their innerHTML to equal that of a cell with id ‘subtotal’. This is a simplified html code of single cell inserted rows:
[U][B]index.html
[code=html]
<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”>$ 15.00</td>
</tr>
<!–3rd inserted row at row index 0 innerHTML should be ‘$ 75.00’–>
<tr class=”itemrow”>
<td class=”rowsubtotal”>$ 20.00</td>
</tr>
<!–2nd inserted row at row index 0 innerHTML should be ‘$ 75.00’–>
<tr class=”itemrow”>
<td class=”rowsubtotal”>$ 40.00</td>
</tr>
<!–1st inserted row at row index 0 innerHTML should be ‘$ 75.00’–>
<tr class=”dummy”>
<td class=”message”>Thank You</td>
</tr>
</tbody>
These functions are not working and I’m not sure I can get javascript functions that will.
[U][B]product.js
[CODE]
function checksubtotal(){
var subtotal=document.getElementById(‘subtotal’).innerHTML;
var rowsubtotals=document.getElementsByClassName(‘rowsubtotal’);
for(var i=0; i< rowsubtotals.length; i++){
var rowsubtotal=rowsubtotals[i];
if(rowsubtotal.innerHTML!==subtotal){ //comparison ‘!==’ ???
rowsubtotal.innerHTML=subtotal; }
else{ rowsubtotal.innerHTML=subtotal; }}//throws syntax error?
function deleterow(a) { // remove row
var row=a.parentNode.parentNode;
row.parentNode.removeChild(row);
var sTotal=sumsubtotal();
//don’t know what this is but seems to work??
EvalSound4(); checksubtotal();
//doesn’t work??
Not sure if this is the wrong approach, might have to use a
!match syntax. Any help greatly appreciated?