I want to calculate math.min to exclude zero from the output. I am not a professional one, and working just to make this project work. so if you guys have any advanced coding that would do my job, that would also be appreciated.
For e.g. If i input 1245 and 1360, output should be 1245. But if I input 1245 and 0, output should be 1245 instead of 0;
I have pasted part of the code of my project here:
<!DOCTYPE html>
<html>
<style>
table
{
align: center;
max-width:640px;
}
td
{
border: 1px solid ORANGE;
border-radius: 5px;
padding: 1% 1%;
background-color:#EADBF5;
}
</style>
<script language="javascript">
function dbkcalc()
{
var decde = Math.min(document.getElementById('DECDAPR').value, document.getElementById('DECDAPC').value);
document.getElementById('DECDE').value= decde;
}
</script>
<body>
<table align="center" width="100%" height="100%">
<tr>
<td>DRAWBACK AS PER RATE</td>
<td><input id="DECDAPR"></td>
</tr>
<tr>
<td>DRAWBACK AS PER CAP</td>
<td><input id="DECDAPC"></td>
</tr>
<tr>
<td colspan=2>
<input id="CALDIF" type="button" class="button" value="CALCULATE" onClick="dbkcalc()">
</td>
</tr>
<tr>
<td><U>DRAWBACK ENTITLED</U></td>
<td class="declared"><U><output id="DECDE" type="number"></U></td>
</tr>
</table>
</body>
</html>
I think it can help you.
function dbkcalc()
{
if (document.getElementById('DECDAPR').value * document.getElementById('DECDAPC').value == 0) {
var decde = Math.max(document.getElementById('DECDAPR').value, document.getElementById('DECDAPC').value);
}
else {
decde = Math.min(document.getElementById('DECDAPR').value, document.getElementById('DECDAPC').value);
}
document.getElementById('DECDE').value= decde;
}
table
{
align: center;
max-width:640px;
}
td
{
border: 1px solid ORANGE;
border-radius: 5px;
padding: 1% 1%;
background-color:#EADBF5;
}
<table align="center" width="100%" height="100%">
<tr>
<td>DRAWBACK AS PER RATE</td>
<td><input id="DECDAPR"></td>
</tr>
<tr>
<td>DRAWBACK AS PER CAP</td>
<td><input id="DECDAPC"></td>
</tr>
<tr>
<td colspan=2>
<input id="CALDIF" type="button" class="button" value="CALCULATE" onClick="dbkcalc()">
</td>
</tr>
<tr>
<td><U>DRAWBACK ENTITLED</U></td>
<td class="declared"><U><output id="DECDE" type="number"></U></td>
</tr>
</table>