PHP code to generate a sum total

I need some quick help.

I have a form in expression engine that offers visitors choices on levels of support to pay for. There are two amounts I’d like to add together and display a total in the totaldue field adding together the $1850 and the sponsor level chosen from the four choices. Can any of you php experts help?

Thanks,

Bill

Here’s the form code:

{exp:freeform:form form_name=“Corporate Partner Registration” required=“firstname1|email” form_title =“Corporate Partner Registration” notify=“email@hidden” return=“http://pacwestsfs.org/index.php/Conference/thanks/”}

Corporate Partner Name

Membership Fee (Single or Double Membership included in Conference Participation Fee)

Conference Participation Fee ($1850)

Corporate Partnership Sponsor Level (choose one)
Platinum $3,000 donation Gold $2,000 donation Silver $1,000 donation Bronze $500 donation

Total Fee Due (please add amounts above to include single or double membership fee,
conference participation fee and corporate sponsorship donation)

Please mail payment to:

Pacific Western Student Financial Services Association

10920 Wilshire Blvd Ste 150

Box 9248

Los Angeles, CA 90024-3990

Comments

Contact information:
(in case we have questions)

First Name

Last Name

Email

{/exp:freeform:form}


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If I understand what you mean then you will need to send ‘POST’ the
form to get the result, if you use javascript then that could be
written to auto calc the total as the selection is made.

HTH


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

thanks Mike, auto calc would work…how and what code could I insert to do that?

Bill


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This would of course not work if the user has javascript turned off so
it would make sense to check the totals on the form processing side so
it the calculation was not made because javascript was off, then the
script could add the totals for you and set them in the email.

  1. Go to Page > Form setup… and then select the ‘Hidden fields’
    tab, add a hidden field to your form, give it a name of a1 and a value
    of 1850

  2. Select the ‘Extend Form’ tab and press new, then give name of name
    and a value of f

  3. Add a text field somewhere you want the total to show on your form
    and call it totalfield

  4. Add your menu item with the various amounts the user needs to
    select for the calculation, give this menu a name of b1

  5. Select the menu and then select Item > Extend from the top menu,
    press New and then en ter onchange for the name and calculate() for
    the value.

  6. Select the total field you added and then go to the Item > Extended
    menu, press new and add readonly for the name with no value.

  7. Add the ‘Form Element Styler’ action to the ‘totalfield’ text field
    and then enter a border width of 1, set the ‘border-colour’ to ffffff,
    if the background of your form is not white then set the ‘border-
    color’ and ‘background-color’ to the same colour as your background.

  8. add the following javascript to the 'Before ’ in the ‘Page >
    HTML’ Markup menu window.

I haven’t actually tested this, I just pulled some javascript from a
calulation page I have and quickly edited it to suite. You should
enter the above javascript into BBEdit and check for hidden chars that
are little black balls and replace then with a space.

HTH
Mike

On Jan 4, 2009, at 12:53 AM, WilliamMac wrote:

thanks Mike, auto calc would work…how and what code could I insert
to do that?

Bill


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Mike, not sure if I can use this in expression engine…but
I’ll give it a try.

Bill

On Jan 4, 2009, at 3:26 AM, Mike B wrote:

This would of course not work if the user has javascript turned off
so it would make sense to check the totals on the form processing
side so it the calculation was not made because javascript was off,
then the script could add the totals for you and set them in the
email.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I am not sure either, but if you can just be aware that some of the code has wrapped and some has actually been spread out onto one line by this application, so if you can then let me know and I will email the code to you in a BBEdit file so these problems are removed.

Mike


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Don’t forget http://pastie.org for easy sharing of code without tears…

Walter

On Jan 4, 2009, at 1:42 PM, Mike B wrote:

I am not sure either, but if you can just be aware that some of the
code has wrapped and some has actually been spread out onto one line
by this application, so if you can then let me know and I will email
the code to you in a BBEdit file so these problems are removed.

Mike


dynamo mailing list
email@hidden
Update your subscriptions at:
List Options | FreewayTalk


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options