Results 1 to 3 of 3

Thread: Calculator working out percentages

  1. #1
    Join Date
    Jun 2010
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Calculator working out percentages

    Hello

    If you go to this page https://www.barnardos.org.uk/donate/...ingle+Donation
    and enter a donation amount and then click on the yes box you will see the percentage of the gift aid is worked out.

    Can anyone help with a JS way to do this please?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,027
    Thanks
    44
    Thanked 3,210 Times in 3,172 Posts
    Blog Entries
    12

    Default

    Code:
    document.getElementById('giftAid_IncomeAgreement').onclick = function(){ //the checkbox
    	if(this.checked){
    		var base = document.getElementById('don_amount').value, //the input with the amount's value
    		added = base * 0.25,
    		total = +base + added;
    		total = total.toFixed(2); //pad/crop to 2 decimal places
    		document.getElementById('giftAidMessage').innerHTML = 'Total amount with Gift Aid ' + total; //a span after the input
    	} else {
    		document.getElementById('giftAidMessage').innerHTML = ''; //that same span
    	}
    }
    Last edited by jscheuer1; 08-23-2013 at 05:04 PM. Reason: improvements
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2010
    Posts
    45
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks this works now, solved

Similar Threads

  1. Coordinate Width:Height Percentages for Images (Shrunk on Browser Resize)
    By questions in forum Looking for such a script or service
    Replies: 4
    Last Post: 05-24-2013, 06:57 PM
  2. Age calculator using php
    By riancast in forum PHP
    Replies: 2
    Last Post: 03-09-2013, 08:30 AM
  3. Distance Calculator not working in IE
    By Stiny.net in forum JavaScript
    Replies: 0
    Last Post: 08-10-2009, 06:58 PM
  4. ??? about percentages
    By apoc.3.21 in forum HTML
    Replies: 1
    Last Post: 07-25-2008, 07:47 PM
  5. percentages and ie
    By james438 in forum CSS
    Replies: 1
    Last Post: 08-10-2007, 07:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •