我想计算 math.min 以从输出中排除零?
I want to calculate math.min to exclude zero from the output?
我想计算 math.min 以从输出中排除零。
我不是专业人士,只是为了让这个项目成功而工作。所以如果你们有任何高级编码可以完成我的工作,那也将不胜感激。
例如
如果我输入 1245 和 1360,输出应该是 1245。
但是如果我输入 1245 和 0,输出应该是 1245 而不是 0;
我把我项目的部分代码贴在这里:
<!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>
我觉得可以帮到你。
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>
我想计算 math.min 以从输出中排除零。 我不是专业人士,只是为了让这个项目成功而工作。所以如果你们有任何高级编码可以完成我的工作,那也将不胜感激。
例如 如果我输入 1245 和 1360,输出应该是 1245。 但是如果我输入 1245 和 0,输出应该是 1245 而不是 0;
我把我项目的部分代码贴在这里:
<!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>
我觉得可以帮到你。
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>