我一直在尋找網絡和SO大約一個星期的時間來解決(對我來說)一個複雜的答案,我相信。請注意,JS和我並不是真正的好朋友。使用Javascript的不同調用(add,substract,substract by perentage ...)
我有需要以下計算可知代碼4個細胞的表:
<table>
<tr>
<td><input type="text" id="price1" name="price1"></td>
<td><input type="text" id="quantity1" name="quantity1"></td>
<td><input type="text" id="discount1" name="discount1"></td>
<td><input type="text" id="total1" name="total1"></td>
</tr>
</table>
Basicaly我需要的是一個動態的解決方案,當我在第一輸入輸入價格示例200中,數量3,和50(百分比)最後的輸入應該做數學,乘以200x3和susbtract折扣(IF折扣),並把結果在輸入total1。
不,我的表AKA形式,是用來製造爲客戶報價,我有一個JS腳本,將線(這就是爲什麼ID和名字的有1個在前面,每條線增加了旁邊的一個數字。
比同樣的腳本,應該計算總計,添加所有總計可用,puting結果在輸入稱爲grandtotal例
<table>
<tr>
<td><input type="text" id="price1" name="price1"></td>
<td><input type="text" id="quantity1" name="quantity1"></td>
<td><input type="text" id="discount1" name="discount1"></td>
<td><input type="text" id="total1" name="total1"></td>
</tr>
<tr>
<td><input type="text" id="price2" name="price2"></td>
<td><input type="text" id="quantity2" name="quantity2"></td>
<td><input type="text" id="discount2" name="discount2"></td>
<td><input type="text" id="total2" name="total2"></td>
</tr>
<tr>
<td><input type="text" id="price3" name="price3"></td>
<td><input type="text" id="quantity3" name="quantity3"></td>
<td><input type="text" id="discount3" name="discount3"></td>
<td><input type="text" id="total3" name="total3"></td>
</tr>
<tr>
<td>grand total</td>
<td><select><option value="10">VAT 10%</option value="20é><option>VAT 20%</option></select>
<td>VAT = (shows only the taxes of the amount)</td>
<td>grand total = all totals + the vat</td>
</tr>
</table>
而且,因爲這個事情是複雜的,我需要一個js腳本,將計算在選擇選項中,客戶需要支付多少錢如果我選擇20%,結果將顯示在<p></p>
中g的20%蘭特總額+增值稅。
兩天前我在stackoverflow的JSfiddle中找到了一張表,但是我的電腦崩潰了,而且我一直在搜索沒有任何運氣。
如果有人可以通過向我展示工作代碼的jsfiddle來提供幫助,我們將非常感謝。
非常感謝您的時間。
這裏有大約計算器崗位100多個。當然,你最終發現了一些想法是如何完成的。至少提供一個嘗試,否則它聽起來像你期望有人爲你做所有這些 – charlietfl 2014-12-27 16:34:20
看看knockout.js – 2014-12-27 16:36:33
大多數與計算器的ost不工作,我試過他們在jsfiddle manualy,他們大多數只是不要不會跑。我已經試過我的方式,我一直封鎖 – Garo 2014-12-27 19:23:14