jquery - Disabling a textbox if it has value and ignored this disabled value in addition and subtraction in javascript -


i want add id= lr1, lr2 & lr3 total show in id=tlrr , subtract id=totalamt.

html code.

<tr>       <td width="125"><b>receiving quarantine </b></td>       <td>         <input type="textbox" name="rcv_quantity" class="tqty" id="totalamt"  value="<?php echo $row->rcv_quantity; ?>" />  </td>     </tr>      <tr>       <td width="125"><b>lot released-1 </b></td>       <td>          <input type="textbox" name="lot_rel1" id="lr1" class="lr" value="<?php echo $row->lot_rel1; ?>" />   </td>     </tr>      <tr>       <td width="125"><b>lot released-2 </b></td>       <td>          <input type="textbox" name="lot_rel2" id="lr2" class="lr" value="<?php echo $row->lot_rel2; ?>" />   </td>     </tr>      <tr>       <td width="125"><b>lot released-3 </b></td>       <td>          <input type="textbox" name="lot_rel3" id="lr3" class="lr" value="<?php echo $row->lot_rel3; ?>" />   </td>     </tr>      <tr>       <td width="125"><b>total lot released </b></td>       <td>          <input type="textbox" name="total_lot_rel" id="tlrr" class="tlr" value="<?php echo $row->total_lot_rel; ?>" />   </td>     </tr> 

javascript addition , subtraction:it works nice.

<script> $(document).ready(function () {     $('.lr').val(0); // reset     $('.lr,#re').keyup(function () {     $('.tqty, #totalamt').val(<?php echo $row->rcv_quantity; ?>);     $('.tlr,#tlrr').val(<?php echo $row->total_lot_rel; ?>);     // loop through inputs , re-calculate total     var total = parsefloat(totalamt.value);     var total_lr = parsefloat(tlrr.value);     $('.lr,#re').each(function () {     // "+" before variable makes sure it's number instead of string     // "or 0" makes 0 if it's empty, instead of "undefined"     var number = +$(this).val() || 0;      // console.log(number);       total -= +number; // adds numbers     decimal = parsefloat(total).tofixed(2);      // sets total 2 decimal places     });      //----------------------------     $('.lr').each(function () {      var number = +$(this).val() || 0;     total_lr += +number;      decimal1 = parsefloat(total_lr).tofixed(2); // sets total 2 decimal places     });     //--------------------------------     // update total     $('#totalamt').val(decimal);     $('#tlrr').val(decimal1);     //$('#notrbl1').val(decimal);     }); }); </script> 

but not disable textbox has value , these textbox participate addition , subtraction.javascript textbox disable

window.onload = function() {   if (document.getelementbyid("lr1").value != null) { ddocument.getelementbyid('lr1')     .setattribute('disabled', 'disabled');   } else if (document.getelementbyid("lr2").value != null) { ddocument.getelementbyid('lr2')     .setattribute('disabled', 'disabled');       } else if (document.getelementbyid("lr3").value != null) { ddocument.getelementbyid('lr3')     .setattribute('disabled', 'disabled');       } } 

i want when lr1 input subtract totalamt , and lr1 value show in tlrr. when want input lr2 lr1 disable , lr2 subtract totalamt , add tlrr.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -