亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法在Ajax計算表格中獲得總計

無法在Ajax計算表格中獲得總計

qq_遁去的一_1 2021-05-20 16:14:00
我創建了這樣的表單:問題是我無法獲得子總計字段的總計。我嘗試創建與總計總計相同的總計字段,但是沒有運氣。我想知道我是否犯了一個錯誤,即沒有在全局范圍內創建一些變量?有沒有簡單的解決方案可以做到這一點?您可以在這里找到完整的代碼:http : //autopartsdiscountcoupons.com/table/Form.html$("#con_qty116").bind('keyup mouseup', function() {  var rate = 40;  var qty = $("#con_qty116").val();  var val = qty * rate;  $("#con_qty116_td").text(val);  sub_total_of_weather_sheild();});$("#con_qty117").bind('keyup mouseup', function() {  var rate = 160;  var qty = $("#con_qty117").val();  var val = qty * rate;  $("#con_qty117_td").text(val);  sub_total_of_decorative_surface();});function sub_total_of_weather_sheild() {  var td116 = parseInt($("#con_qty116_td").text());  var sub_tot = td116;  $("#weather_sheild_qty_sub_total").text(sub_tot);  gr_total(sub_tot);}function sub_total_of_decorative_surface() {  var td117 = parseInt($("#con_qty117_td").text());  var sub_tot = td117;  $("#decorative_surface_qty_sub_total").text(sub_tot);}  <td>116</td>  <td>Provide and apply Weathershield (Reputable Brand) minimum...  </td>  <td>Sft</td>  <td><input id="con_qty116" name="con_qty116" type="number" /></td>  <td>40</td>  <td id="con_qty116_td">0</td>  <th colspan="4">Sub Total</th>  <td id="weather_sheild_qty_sub_total" colspan="2">0</td>  <td>117</td>  <td>Color Crete min 4mm thickness including surface preparation applied on prepared surface using Applicant Machine/Gun  </td>  <td>Sft</td>  <td><input id="con_qty117" name="con_qty117" type="number" /></td>  <td>160</td>  <td id="con_qty117_td">0</td></tr><tr>  <th colspan="4">Sub Total</th>  <td id="decorative_surface_qty_sub_total" colspan="2">0</td></tr><th colspan="4">Grand Total</th><th colspan="2" id="grand_total">0</th>
查看完整描述

2 回答

?
慕娘9325324

TA貢獻1783條經驗 獲得超4個贊

在每個功能上,當您更新小計時,您還將獲得每個小計,并將所有這些總和相加并放入小計。請按照以下步驟操作:-


在grand_total()函數中獲取每個小計的值


function grand_total(){

  var grand_total = parseInt($("#ew_qty_sub_total").text());

  grand_total += parseInt($("#con_qty_sub_total").text());

  grand_total += parseInt($("#rein_qty_sub_total").text());

  .

  .       

  .   


 grand_total += parseInt($("#weather_sheild_qty_sub_total").text());

 grand_total += parseInt($("#decorative_surface_qty_sub_total").text());


 $("#grand_total").text(grand_total);


}     

在每個keyup / mouseup函數中調用此函數。像這樣:-


$("#ew_qty1").bind('keyup mouseup',function ()

{


  var rate = 12;

  // Take Quantity from user

  var qty = $("#ew_qty1").val();


  // Multiply Quantity By 10

  var val = qty*rate;


  // Set Text In TD

  $("#ew_qty1_td").text(val);

  sub_total_of_earth_Work();


  grand_total();   //call for total of sub total 



});


查看完整回答
反對 回復 2021-05-27
  • 2 回答
  • 0 關注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號