If someone can point me to a tutorial somewhere that would help me with parent / child examples that would be very helpful, or maybe you can answer my questions specifically.
Here is some sample html:
<table>
<tr id="ABC123" sku="ABC123"><td class="itemno">ABC123 <input type="hidden" name="qdItem.SKU.N1" value = "ABC123"></td>
<td class="liDescription">hello world</td>
<td><input type="text" name="qdItem.Price.N1" class="liQuotePrice" value = "27">
<input type="hidden" name="qdItem.orgPrice.N1" class="orgQuotePrice" value = "27">
<input type="hidden" name="qdItem.Cost.N1" class="qpc" value = "21.78">
</td>
<td>35.11 <input type="hidden" name="qdItem.RPL.N1" VALUE = "35.11"></td>
<td> </td>
<td>22.86 <input type="hidden" name="qdItem.ICL.N1" VALUE = "22.86" ></td>
<td> </td>
<td><input type="text" name="qdItem.Quantity.N1" value="21" class="liQty">
</td>
<td class="GM">19.3333333333%</td>
<td> </td>
<td> </td>
<td class="delcolumn"><img src="images/trash.png" class="icon" alt="delete" title="delete line item"></td>
</tr>
<tr id="DDD999" sku="DDD999"><td class="itemno">DDD999 <input type="hidden" name="qdItem.SKU.N2" value = "DDD999"></td>
<td class="liDescription">a description of my item</td>
<td><input type="text" name="qdItem.Price.N2" class="liQuotePrice" value = "43">
<input type="hidden" name="qdItem.orgPrice.N2" class="orgQuotePrice" value = "43">
<input type="hidden" name="qdItem.Cost.N2" class="qpc" value = "21.9996152147">
</td>
<td>35.46 <input type="hidden" name="qdItem.RPL.N2" VALUE = "35.46"></td>
<td> </td>
<td>22.88 <input type="hidden" name="qdItem.ICL.N2" VALUE = "22.88" ></td>
<td> </td>
<td><input type="text" name="qdItem.Quantity.N2" value="22" class="liQty">
</td>
<td class="GM">48.8381041518%</td>
<td> </td>
<td> </td>
<td class="delcolumn"><img src="images/trash.png" class="icon" alt="delete" title="delete line item"></td>
</tr>
</table>
Here is some javascript that is not working:
$(document).ready(function(){
$(this).find('.liQuotePrice').change(function() {
var content = $('.orgQuotePrice').val();
console.log(content + '(original price');
if ($('.liQuotePrice').val() != content) {
//if ($('.liQuotePrice').val() != content || ($('.liQuotePrice').val() == '')) {
content = $('.orgQuotePrice').val();
console.log('quote price was changed')
//alert($(this).parent('td').parent('tr').attr('sku'));
var SKU = $(this).parent('td').parent('tr').attr('sku');
if ($(SKU).children('td').eq(8)) {
//console.log(SKU);
var cost = $(".qpc").val();
var nqp = $(".liQuotePrice").val();
var newGM = ( ((nqp - cost)/nqp) * 100) ;
newGM = newGM.toFixed(2) + "%";
$(SKU).children('td').eq(8).html(newGM);
console.log(newGM + ' ' + SKU);
cbutton();
}
}
});
});
******************
How do I write my new calculation in the 9th table data element of the row in which I'm editing? There could be lots of rows (more than one anyway). I will also need to write new calculations to other table data elements in the same row.
Linda