JSFiddle - React, Tailwind, and code Playground

by hicurin

HTML

<table>
      <tr>
      <td><input name="amt1" id="txtAmt" type="text" value="" align="left"  style="text-align:center" /></td>
      <td><select name = "drop1" id="sc"><option value="S">Self</option><option value="C">Company</option></select></td>
      </tr>          
         <tr>
           <td>Advance Required</td>
           <td><select name="advReq" id="ad">
               <option value="y">Yes</option>
               <option value="n">No</option>
               </select>
           </td>
           <td><input id='re' name="adv1" type="text" readonly="readonly" value="" /></td>
       </tr>

   </table>

JavaScript

document.getElementById('txtAmt').onkeyup = function(){
    var txtV = parseInt(this.value);
    var re = document.getElementById('re');
    var ad = document.getElementById('ad').value;
    var sc = document.getElementById('sc').value;
    if(ad == 'y'){
        // Yes in Advance Required
        if(sc == 'S'){
            // Self
            re.value = 'Self: ' + (txtV + 750) + '$';
        }
        else{
            re.value = 'Company: ' + (txtV + 750) + '$';
        }
    }
    else{
        // No in Advance Required
        if(sc == 'S'){
            re.value = 'Self: ' + '0.00';
        }
        else{
            re.value = 'Company: ' + '0.00';
        }
    }
}