我遇到的问题是我基于下图的结果显示小数点后 3 位:$242.075 > 而不是 $242.07(图片末尾的数字)
有3个小数位
这一切都在 JavaScript 部分代码底部的“max”变量中
我已经检查了有关此问题的所有重复问题,并按照说明进行了尝试toFixed(2)
,但是当我将其键入为时不起作用
1)var max = (principal/2)-fees.toFixed(2);
和 2)text = text + ' Current fee on account is $' +fees+ '. Maximum additional fee allowed is $' +max.toFixed(2);
我没有收到任何错误,但弹出屏幕不会显示,它只是保留在屏幕上:(。
<script>
function CollFee(input, principal, fees){
var max = (principal/2)-fees;
//var input = this.value;
//alert(input);
if(input.value > max){
input.value = '';
var text = 'Collection Fee is too high, the total of all collection fees can only be 50% of the Original Principal.';
text = text + ' Current fee on account is $' +fees+ '. Maximum additional fee allowed is $' +max;
alert(text);
//document.getElementById('collfee_<?php echo $dbid; ?>').value = '';
//input.value = '';
}
};
</script>
这里是上面部分的代码和 代码末尾的 Java 脚本部分下面的整个代码
<center>
<h1>
Collection Authorization
</h1>
<div class="homemess2" align="center" >
<p class="homemess3">
Please mark each account listed below with a <b>Yes</b> if you <b><u>approve</u></b> it to be placed into our Phase II (Contingency Collections) department.
</p>
<p class="homemess3">
Please mark each account listed below with a <b>No</b> if you <b><u>do not approve</u></b> it to be placed into our Phase II (Contingency Collections) department.
</p>
<p class="homemess3">
Accounts left unmarked will remain on the Collection Authorization List.
</p>
<p class="homemess3">
NEW FEATURE: Now you can authorize accounts to go to Phase II that were 'Previously Declined', simply choose the 'Previously Declined' option in the below menu to see the Phase I accounts that can still be sent to Phase II.
</p>
</div><br>
</center>
<center style="padding-bottom:12px;">
<b>New Feature : </b>
<select id="dynamic_select">
<option value="rep_collauthorization.php" selected="selected">Collection Authorization</option>
<option value="rep_collauthorization_declined.php">Previously Declined</option>
<option value="rep_collauthorization_combined.php">Combined</option>
</select>
</center>
<form method="post" action="rep_collauthorizationx.php">
<table class="ttable sort_ttable1" id="addsearchres" summary="Address Search">
<caption class="ttable">Collection Authorization List</caption>
<thead class="ttable">
<tr class="ttable">
<th class="ttable" width="30" id="Y">Yes</th>
<th class="ttable" width="30" id="N">No</th>
<th class="ttable" width="100" id="CR">Collection Fee</th>
<th class="ttable" id="LN">File</th>
<th class="ttable" id="LS">Debtor</th>
<th class="ttable" id="LS">Responsible</th>
<th class="ttable" id="NB">City</th>
<th class="ttable" id="NB">St</th>
<th class="ttable" id="NB">Original Principal</th>
<th class="ttable" id="NB">Balance</th>
</tr>
</thead>
<tbody class="ttable">
<?php
$tprisec = "tprimary";
$anumberaccount = "";
$numberaccount = 0;
include './includes/dblogin.php';
$sql_stmt = generate_coll_authorization_list();
$qresult = mysql_query($sql_stmt);
if (!$qresult) {
print(mysql_error());
}
if ($qresult && mysql_num_rows($qresult) > 0 ) {
echo "<input type='hidden' name='client_rowid' value='".$client_rowid."'";
while ($row = mysql_fetch_array($qresult, MYSQL_ASSOC)) {
$dbfees = 0;
$dbid = $row["de_number"];
$dbcontact = $row["de_contact"];
$dbaddress = $row["de_address"];
$dbcity = $row["de_city"];
$dbstate = $row["de_state"];
$dbzip = $row["de_zip"];
$dbrname = $row["de_name"];
$dblisted = $row["de_listed_date"];
$dbaccount = substr($row["de_cl_account"], 0, 15);
$dbprincipal = $row["de_principal"];
$dp= substr($dbprincipal, -2, 2);
if ($dp=='00'){
$dbprincipal= substr ($dbprincipal, 0, -2);
}
$dbfees = $row["de_fees"];
$dbowing = $row["de_owing"];
$dow= substr($dbowing, -2, 2);
if ($dow=='00'){
$dbowing= substr ($dbowing, 0, -2);
}
$dbstatus = substr($row["de_statusnew"], 0, 3);
echo "<tr class='".$tprisec."'>";
echo "<td class='ttablex' align='center'>";
echo "<input type='radio' name='".$dbid."' value='Yes'";
echo "</td>";
echo "<td class='ttablex' align='center'>";
echo "<input type='radio' name='".$dbid."' value='No'";
echo "</td>";
echo "<td class='ttablex' align='center'>";
//echo "<input class='collfee' onchange='CollFee(this.value, '$dbprincipal', '$dbfees')' id='collfee_".$dbid."' type='text' name='cf_".$dbid."' size='8'>";
?>
<input class='collfee' onchange="CollFee(this, '<?php echo $dbprincipal; ?>', '<?php echo $dbfees; ?>')" id='collfee_<?php echo $dbid;?>' type='text' name='cf_<?php echo $dbid;?>' size='8'>
<?php
echo "</td>";
echo "<td class='ttablex' align='right'>".$dbid."</td>";
echo "<td class='ttablex' align='left'>".$dbcontact."</td>";
echo "<td class='ttablex' align='left'>".$dbrname."</td>";
echo "<td class='ttablex' align='left'>".$dbcity."</td>";
echo "<td class='ttablex' align='left'>".$dbstate."</td>";
echo "<td class='ttablex' align='right'>".$dbprincipal."</td>";
echo "<td class='ttablex' id='principal_amt' align='right'>".$dbowing;
echo "<input id='pamt_".$dbid."' class='pamt' type='hidden' name='pamt_".$dbid."' value=".$dbprincipal.">";
echo "</td>";
echo "</tr>";
if ($tprisec == "tprimary") {
$tprisec = "tsecondary";
} else {
$tprisec = "tprimary";
}
$numberaccount ++;
}
$anumberaccount = number_format($numberaccount,0);
}
echo "</tbody>";
echo "</table>";
$anumberaccount = number_format($numberaccount,0);
if($anumberaccount == '1') {
echo "<br>There is ".$anumberaccount." account.<br><br>";
} else {
echo "<br>There are ".$anumberaccount." accounts.<br><br>";
}
?>
<center>
<input type="submit" name="terms" id="terms" value="Terms and Conditions"><br>
<input type="checkbox" name="readagreed" id="readagreed" value="terms">I have read and agree to the Terms and Conditions.<br><br><br>
<input type="submit" name="submit" id="submit" value="Submit">
<input type="reset" value="Reset"><br>
</center>
<input type="submit" name="submit_real" id="submit_real">
</form>
<script>
function CollFee(input, principal, fees){
var max = (principal/2)-fees;
//var input = this.value;
//alert(input);
if(input.value > max){
input.value = '';
var text = 'Collection Fee is too high, the total of all collection fees can only be 50% of the Original Principal.';
text = text + ' Current fee on account is $' +fees+ '. Maximum additional fee allowed is $' +max;
alert(text);
//document.getElementById('collfee_<?php echo $dbid; ?>').value = '';
//input.value = '';
}
};
</script>