ipwnzphp Posted July 15, 2008 Share Posted July 15, 2008 On the t7 text box it shows document.invoice.price_1.value * document.invoice.qty_1.value where price_1 and qty_1 is dynamic so it could show 2 or 3 or 4 and etc. You will see this in the code. Below is my code. Please take a look been messing with this for 5 hours now! Everything else works prefect just this part is a little freaky! What i am trying to do is this when we make a new dynamic row we can enter the cost pre item and qty of the item and then it spits back a total price after we enter the qty of them item in. <script type="text/javascript"> function addrows(cid) { var tbody = document.getElementById(cid).getElementsByTagName("TBODY")[0]; var row = document.createElement("TR"); var numi = document.getElementById('theValue'); var num = (document.getElementById('theValue').value -1)+ 2; numi.value = num; var t1 = document.createElement("TD"); t1.innerHTML = '<a href="javascript:;" onClick="addrows(\'myTable\')">Add</a> - <a href="javascript:;" onClick="removerows(this)">Remove</a>'; var t2 = document.createElement("TD"); t2.innerHTML = '<select name="item_'+num+'"><option value="0">-------</option><option value="1">Service</option><option value="2">Product</option></select>'; var t3 = document.createElement("TD"); t3.innerHTML = '<textarea name="desc_'+num+'" cols="35" rows="4" disabled></textarea>'; var t4 = document.createElement("TD"); t4.innerHTML = '<input name="price_'+num+'" type="text" size="12" />'; var t5 = document.createElement("TD"); t5.innerHTML = '<input name="qty_'+num+'" type="text" size="6" onChange="addits()"/>'; var t6 = document.createElement("TD"); t6.innerHTML = '<select name="tax_'+num+'"><option value="0">0%</option><option value="1">10%</option></select>'; var t7 = document.createElement("TD"); t7.innerHTML = '<input type="text" name="g" size="5" maxlength="5">'; row.appendChild(t1); row.appendChild(t2); row.appendChild(t3); row.appendChild(t4); row.appendChild(t5); row.appendChild(t6); row.appendChild(t7); tbody.appendChild(row); } function removerows(node) { var tr = node.parentNode; while (tr.tagName.toLowerCase() != "tr") tr = tr.parentNode; tr.parentNode.removeChild(tr); var numi = document.getElementById('theValue'); var num = (document.getElementById('theValue'). value -1); numi.value = num; } // This is not working right function addits() { var prd = (document.getElementById('theValue') . value); document.invoice.g.value = 'document.invoice.price_'+prd+'.value * document.invoice.qty_'+prd+'.value'; } // end of not working right function addit() { document.invoice.s.value = document.invoice.price_0.value * document.invoice.qty_0.value } </script> Link to comment https://forums.phpfreaks.com/topic/114794-javascript-acting-werid/ Share on other sites More sharing options...
ipwnzphp Posted July 15, 2008 Author Share Posted July 15, 2008 Firefox error console said this Error: uncaught exception: [Exception... "Cannot modify properties of a WrappedNative" nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)" location: "JS frame :: chrome://global/content/bindings/autocomplete.xml :: onxblpopuphiding :: line 834" data: no] Link to comment https://forums.phpfreaks.com/topic/114794-javascript-acting-werid/#findComment-590247 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.