Skip navigation
Currently Being Moderated

Why wont the '£ ' sign sit next to value?

Mar 19, 2013 12:08 PM

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'

 

http://www.milesmemorials.com/estimator.html

 
Replies
  • Currently Being Moderated
    Mar 19, 2013 12:39 PM   in reply to Ness_quick

    Try adding margin:0 to the styles for that <input> tag.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 19, 2013 3:01 PM   in reply to Ness_quick

    THen change margin to padding. It worked for me with your code.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 2:21 AM   in reply to Ness_quick

    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">&pound;

                          </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.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 3:00 AM   in reply to Ness_quick

    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'

     

    http://www.milesmemorials.com/estimator.html

     

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 3:43 AM   in reply to osgood_

    > I don't know how to force the field to show the '0' but it must be possible.

     

    Use Javascript Number method toFixed():

    var n = 4791.1;

    var s = n.toFixed(2);

    console.log(s); // output "4791.10"

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 3:52 AM   in reply to kennethkawamoto2

    Hi Ken,

     

    Out of curiosity (it's not my job) but how will your solution fit in with the below?

     

     

    cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value)

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 4:01 AM   in reply to osgood_

    > how will your solution fit in with the below?

    cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value).toFixed(2 );

    cemetery_fee is now a String (not a Number) with always two fractions.

     

    --

    Kenneth Kawamoto

    htp://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 4:04 AM   in reply to kennethkawamoto2

    Ok Ken thanks or I guess you could just do the below (i'm not as well versed as you are at javascript)

     

    cemetery_fee = Number(document.catwebformform22057.CAT_Custom_76931.value)

    cemetery_fee = cemetery_fee.toFixed(2)

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 4:10 AM   in reply to Ness_quick

    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);

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 4:20 AM   in reply to osgood_

    @ 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

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 4:23 AM   in reply to kennethkawamoto2

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 4:27 AM   in reply to Ness_quick

    @ Ness, what's your code?

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 4:28 AM   in reply to kennethkawamoto2

    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

    http://www.materiaprima.co.uk/

     

    That makes sense to me

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 4:37 AM   in reply to Ness_quick

    @ 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

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 4:46 AM   in reply to kennethkawamoto2

    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!

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2013 5:11 AM   in reply to Ness_quick

    You need to add two Numbers first then convert it to a String:

     

    document.catwebformform22057.grand_total.value = (total_funeral + total_disbursements).toFixed(2);

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points