I have some piece of code where I am using javascript to assign a value to a cell. The code is working perfectly. However, when the user presses shift + tab (BackTab), the cell resets the value to its default. How could I prevent this. The sample of my code is as follows.

function totalamount20(varserialnumber4, totalcount2) {
  var tax = document.getElementById("tax" + varserialnumber4).value;
  if (tax != '') {
    ...somecode
  }
  else {
    ...somecode
  }
}
<td bgcolor="#ffffff" class="bodytext31" valign="center" align="center">
  <strong>Tax</strong>
</td>
<td class="bodytext31" valign="center" align="left">
  <div align="center">
    <input type="text" name="tax[]" id="tax<?php echo $sno; ?>" size="6" onKeyUp="return totalamount20('<?php echo $sno; ?>','<?php echo $number; ?>');" class="bodytext21" autocomplete="off" readonly>
  </div>
</td>

0 Answers