Why wont the pound sign sit next to the value on the- 'Sub cost of Funeral' It keeps sitting above the value and yet all the other pound signs and values are fine.
Also, why when selecting the 'Burial' section and adding 'St Sebastians Non-res (£4791.10)' from the 'Cemetery fees' drop down menu do i only get £4791.1 instead of £4791.10 in the 'Total Disbursements for a Burial'. Its missing the last figure? It also does the same in the 'Total cost of funeral'
Ness_quick wrote:
Why wont the pound sign sit next to the value on the- 'Sub cost of Funeral' It keeps sitting above the value and yet all the other pound signs and values are fine.
I don't know, the code is getting a bit bloated and hard to figure out when these errors occur. Desperate times call for desperate measures. Copy the 'Total Cost of Funeral' html and replace the code which doesn't work but obviously use the correct <input> name NOT grand_total
<tr>
<td> </td>
<td> </td>
<td class="estimatortext"><br />
Total Cost of Funeral</td>
<td><br />
<span class="estimatortext">£
</span>
<input name="grand_total" style="text-align: right; font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif; color: #C3A328; font-size: 18pt; border: 0px; background-color: #F4ECC5;" type="text" size="3" gtbfieldid="141" /></td>
</tr>
<tr>
I see you have merged the table cells in that particular table row. That's never a good idea. It could be as simple as something like that which is the root cause.
Ness_quick wrote:
Also, why when selecting the 'Burial' section and adding 'St Sebastians Non-res (£4791.10)' from the 'Cemetery fees' drop down menu do i only get £4791.1 instead of £4791.10 in the 'Total Disbursements for a Burial'. Its missing the last figure? It also does the same in the 'Total cost of funeral'
Interestingly it only happens when there is a '0' at the end of the decimal i.e., 1492.10 but if you have this 1492.11 the whole number is shown.
I don't know how to force the field to show the '0' but it must be possible.
@ Os, no I wouldn't do it like that.
cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value)
cemetery_fee = cemetery_fee.toFixed(2)
In your code cemetery_fee is a Number in the first line but changed to a String in the second line. While Javascript is perfectly happy to coerce data types dynamically, now you can't use cemetery_fee in further mathematical calcurations because it's not a Number any more. I'd do it like this so that you will never mix two different data types:
var cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value); // Number
var cemetery_fee_to_display = cemetery_fee.toFixed(2); // String
--
Kenneth Kawamoto
kennethkawamoto2 wrote:
To display the number with two fractions in your script, for example you can do:
document.catwebformform22057.total_burial_disbursements.value = burial_disbursements.toFixed(2);
Right, that's also more efficient.
It looks like I need to learn about javascript as it seems to be quite powerful. I've previously overlooked it because I thought it was just a watered down version of a server language but it's not, it has it own particular uses and I'm finding plenty of uses at the moment as I attempt to do more complex building, which requires decison making instantaneously which a server language cannot do.
Thanks for the input. I'm learning something new every day, which is my goal.
kennethkawamoto2 wrote:
@ Os, no I wouldn't do it like that.
cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value)
cemetery_fee = cemetery_fee.toFixed(2)
In your code cemetery_fee is a Number in the first line but changed to a String in the second line. While Javascript is perfectly happy to coerce data types dynamically, now you can't use cemetery_fee in further mathematical calcurations because it's not a Number any more. I'd do it like this so that you will never mix two different data types:
var cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value); // Number
var cemetery_fee_to_display = cemetery_fee.toFixed(2); // String
--
Kenneth Kawamoto
That makes sense to me ![]()
Right, so ive changed this -
cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value).toFixed(2 );
to this -
var cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value); // Number
var cemetery_fee_to_display = cemetery_fee.toFixed(2); // String
but it has now gone back to missing the '0' again. Or have i done it wrong? Should i have remove the earlier code -
var n = 4791.1;
var s = n.toFixed(2);
console.log(s); // output "4791.10"
@ Ness
> Should i have remove the earlier code
Yes, undo everything you have done - sorry it was meant to be just an example ![]()
Keep your code as it was, but just change the last bit where you display the results, i.e.
document.catwebformform22057.total.value = total_funeral.toFixed(2);
document.catwebformform22057.doctors_fees.value = doctors_fees.toFixed(2);
... etc
--
Kenneth Kawamoto
kennethkawamoto2 wrote:
Yes, undo everything you have done - sorry it was meant to be just an example
Keep your code as it was, but just change the last bit where you display the results, i.e.
document.catwebformform22057.total.value = total_funeral.toFixed(2);
document.catwebformform22057.doctors_fees.value = doctors_fees.toFixed(2);
That fixed it!
North America
Europe, Middle East and Africa
Asia Pacific