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?
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.
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.
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
Select the ‘Extend Form’ tab and press new, then give name of name
and a value of f
Add a text field somewhere you want the total to show on your form
and call it totalfield
Add your menu item with the various amounts the user needs to
select for the calculation, give this menu a name of b1
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.
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.
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.
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?
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.
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.
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.