Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #19470 > unrolled thread
| Started by | linda@ninetypercentnerd.com |
|---|---|
| First post | 2013-04-25 10:02 -0700 |
| Last post | 2013-04-25 12:13 -0700 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.javascript
help with editing a child element linda@ninetypercentnerd.com - 2013-04-25 10:02 -0700
Re: help with editing a child element Denis McMahon <denismfmcmahon@gmail.com> - 2013-04-25 18:09 +0000
Re: help with editing a child element linda@ninetypercentnerd.com - 2013-04-25 12:13 -0700
| From | linda@ninetypercentnerd.com |
|---|---|
| Date | 2013-04-25 10:02 -0700 |
| Subject | help with editing a child element |
| Message-ID | <25b50215-dae1-43de-b595-a21f1a61dea9@googlegroups.com> |
I want to make a change within a form input on a particular table row, make a calculation and write a value to a particular table data element of that particular row.
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
[toc] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-04-25 18:09 +0000 |
| Message-ID | <klbrgh$2pp$2@dont-email.me> |
| In reply to | #19470 |
On Thu, 25 Apr 2013 10:02:40 -0700, linda wrote: > $( ... Error, jquery detected. Please either reformulate the question without jquery (if it is a non jquery issue), or ask in a jquery specific forum (if it is a jquery issue). -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | linda@ninetypercentnerd.com |
|---|---|
| Date | 2013-04-25 12:13 -0700 |
| Message-ID | <b4f28440-64d3-4846-a5f6-c0014ccb5d2a@googlegroups.com> |
| In reply to | #19470 |
On Thursday, April 25, 2013 1:02:40 PM UTC-4, li...@ninetypercentnerd.com wrote:
> I want to make a change within a form input on a particular table row, make a calculation and write a value to a particular table data element of that particular row.
>
>
>
> 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
Sorry .. wrong forum. New here.
Linda
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web