Adding 2 Decimals
Ray:
You recently helped me with the script included below which gives whole numbers as result. How can I allow for two decimals in the result? I have tried using the number_format() function but couldn't make it work
<script type="text/javascript">
var spryselect3 = new Spry.Widget.ValidationSelect("spryselect3", {validateOn:["blur"]});
var spryselect5 = new Spry.Widget.ValidationSelect("spryselect5", {validateOn:["blur"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur"]});
var spryselect6 = new Spry.Widget.ValidationSelect("spryselect6");
var spryselect7 = new Spry.Widget.ValidationSelect("spryselect7");
var spryselect8 = new Spry.Widget.ValidationSelect("spryselect8");
var spryselect9 = new Spry.Widget.ValidationSelect("spryselect9");
function updateTot(row) {
var rowTot = 0;
var theField = document.getElementById("cw_"+row);
if (theField.selectedIndex != 0) rowTot += parseInt(theField.options[theField.selectedIndex].value);
var theField = document.getElementById("con_"+row);
if (theField.selectedIndex != 0) rowTot += parseInt(theField.options[theField.selectedIndex].value);
var theField = document.getElementById("att_"+row);
if (theField.selectedIndex != 0) rowTot += parseInt(theField.options[theField.selectedIndex].value);
var theField = document.getElementById("attpunct_"+row);
if (theField.selectedIndex != 0) rowTot += parseInt(theField.options[theField.selectedIndex].value);
var theField = document.getElementById("part_"+row);
if (theField.selectedIndex != 0) rowTot += parseInt(theField.options[theField.selectedIndex].value);
var theField = document.getElementById("disc_"+row);
if (theField.selectedIndex != 0) rowTot += parseInt(theField.options[theField.selectedIndex].value);
var theField = document.getElementById("proj_"+row);
if (theField.selectedIndex != 0) rowTot += parseInt(theField.options[theField.selectedIndex].value);
var theField = document.getElementById("exAct_"+row);
if (theField.selectedIndex != 0) rowTot += parseInt(theField.options[theField.selectedIndex].value);
document.getElementById("show_"+row).innerHTML = rowTot;
document.getElementById("total_"+row).value = rowTot;
}
</script>
<td width="16%" align="center" valign="middle" class="td7"><span id="show_<?php echo $RepeatSelectionCounter_1; ?>">0</span>
<input type="hidden" name="total_<?php echo $RepeatSelectionCounter_1; ?>" /></td>
Any suggestions?
Thank you for your attention