Note that there are some explanatory texts on larger screens.

plurals
  1. POSums not working with adding and removing Dynamic Fields
    primarykey
    data
    text
    <p>I have a script that calls to a Database to get Autocomplete data. </p> <p>Once the specific Autocomplete data (Item Name) has been chosen a few other fields are populated, namely: Item Code, Price &amp; Quantity.</p> <p>When the quantity is changed the Lines Total field changes to "Quantity * Price" total.</p> <p>There is the option to carry on adding rows Dynamically and autocomplete each in the same fashion ... there is a Grand Total that adds each line total together.</p> <p>My issues are that the grand total only changes when the Quantity is changed, it should load on the focus of Price in each line - also, removing a line does not remove that spcific Line Totals ammount from the Grand Total and if you change the very first lines quantity (only the first line is affected) it re-sets the Grand total to anything that line has now added up to ... Please can someone look at my code.</p> <p>The live version is at <a href="http://cardoso.co.za/form/" rel="nofollow">http://cardoso.co.za/form/</a></p> <p>You can also get the files there too if you browse to <a href="http://cardoso.co.za/form/form.zip" rel="nofollow">http://cardoso.co.za/form/form.zip</a></p> <p>Any and all help is greatly appreciated!!!</p> <p>Edit here's some code from the entire script:</p> <pre><code> var $itemsTable = $('#itemsTable'); var rowTemp = [ '&lt;tr class="item-row"&gt;', '&lt;td&gt;&lt;a id="deleteRow"&gt;&lt;img src="images/icon-minus.png" alt="Remove Item" title="Remove Item"&gt;&lt;/a&gt;&lt;/td&gt;', '&lt;td&gt;&lt;input name="itemType" class="itemType" id="itemType" tabindex="1" style="width:350px;"/&gt;&lt;/td&gt;', '&lt;td align="center"&gt;&lt;input name="itemCode" class="itemCode" id="itemCode" readonly="readonly" style="width:60px;" tabindex="-1"/&gt;&lt;/td&gt;', '&lt;td align="center"&gt;&lt;input name="itemQty" class="itemQty" id="itemQty" tabindex="2" style="width:40px;" maxlength="4" value=""/&gt;&lt;/td&gt;', '&lt;td width="14%" align="center"&gt;&lt;input name="itemPrice" class="itemPrice" id="itemPrice" readonly tabindex="-1"/&gt;&lt;/td&gt;', '&lt;td width="17%" align="right"&gt;&lt;input name="itemTotal" class="itemTotal" id="itemTotal" readonly tabindex="-1"/&gt;&lt;/td&gt;', '&lt;/tr&gt;' ].join(''); $('#addRow').bind('click',function(){ var $row = $(rowTemp); var $itemType = $row.find('#itemType'); var $itemCode = $row.find('.itemCode'); var $itemPrice = $row.find('.itemPrice'); var $itemQty = $row.find('.itemQty'); var $itemTotal = $row.find('.itemTotal'); if ( $('#itemType:last').val() !== '' ) { $row.find('#itemType').autocomplete({ source: 'item-data.php', minLength: 1, select: function(event, ui) { $itemType.val(ui.item.itemType); $itemCode.val(ui.item.itemCode); $itemPrice.val(ui.item.itemPrice); $itemTotal.focus().val(ui.item.itemPrice); $itemQty.focus().val(1); $itemQty.keyup(function() { var Quantity = $itemQty.val(); var Prices = $itemPrice.val(); var ItemsTotal = Quantity * Prices; $itemTotal.val(ItemsTotal.toFixed(2)); var Tsum = 0; $('.itemTotal').each(function() { if(!isNaN(this.value) &amp;&amp; this.value.length!=0) { Tsum += parseFloat(this.value); $('#toTally').val(Tsum.toFixed(2)) } }); }); return false; } }).data( "autocomplete" )._renderItem = function( ul, item ) { return $( "&lt;li&gt;&lt;/li&gt;" ) .data( "item.autocomplete", item ) .append( "&lt;a&gt;" + item.itemType + "&lt;/a&gt;" ) .appendTo( ul ); }; $('.item-row:last', $itemsTable).after($row); $('#minusRow').show(); $('#resetTable').show(); $($itemType).focus(); } return false; }); </code></pre> <p>I have implemented the Array, Will post this instead soon, once I get it to work with ID's and Classes without jamming.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload