7 Replies Latest reply on Feb 7, 2008 5:02 AM by (Laurence_Lewis)

    Calculate fields

    (Laurence_Lewis) Level 1
      Hi

      Is it possible using ADDT to take two form fields with numerical values and have them total in a third field?

      Thanks

      laurence
        • 1. Re: Calculate fields
          Günter Schenk Level 4
          Hi Laurence,

          ADDT can´t do that, but such calculations can be done with javascript. Please google "javascript form calculation"

          Cheers,
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: Calculate fields
            (Laurence_Lewis) Level 1
            Hi Gunter :-)

            I hope all is well in Germany and your drinking enough beer.

            I know it can be done with PHP perhaps javascript is a way to go.

            Cheers
            Laurence of Australia
            • 3. Re: Calculate fields
              Günter Schenk Level 4
              Hi Laurence,

              ----
              Laurence of Australia
              ----

              so you´re not Lawrence of Arabia ? :-)

              -----
              I hope all is well in Germany and your drinking enough beer
              -----

              dang, we germans just had the Carnival season, and we´re all short in supply now ;-)

              ------
              I know it can be done with PHP
              ------

              Well, maybe I misunderstood your question, because I thought you wanted the total to appear in another *form* field.

              However, if you want to calculate two form field values and insert them into a table column, you can establish a Custom Trigger which sums up both transaction values, like this:

              $value_field_one = $tNG->getColumnValue("transaction_column_one");
              $value_field_two = $tNG->getColumnValue("transaction_column_two");
              $total = $value_field_one + $value_field_two;

              ...and then inserts the value of the variable $total into the desired column.

              Cheers,
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: Calculate fields
                (Laurence_Lewis) Level 1
                Excuse me while I adjust my desert cloak and wistfully see an oasis of german larger on the horizon....

                Yes in this instance its in the same form although to confuse things its like this

                I have form a that a user fills in to advertise their event, two fields in that form are:

                Non-Member Ticket price.... and
                Member Ticket price.

                These are carried to a second form where the person registering for the event enters No of member and No of Non-member tickets into the appropriate field

                below this is a total field where the total should be a calculation of price (member) x No member tickets + price (non-member) x No of non-Member tickets

                That should make more sense...Although i will copy your in form solution because that will definately come in handy

                Cheers
                Laurence
                • 5. Re: Calculate fields
                  (Laurence_Lewis) Level 1
                  Oh and you can have a look here

                  http://www.wholecaboodle.com.au/selectEvent.php

                  and the first form come from this one

                  http://www.wholecaboodle.com.au/listEvents.php

                  these are test pages I will delete as soon as I have worked out my problem
                  • 6. Re: Calculate fields
                    Günter Schenk Level 4
                    Well, if those two fields are carried to another form, I´d first assign the field values to a new variable, like this:

                    $member_ticket_price = $_POST['member_ticket_price'];
                    $non_member_ticket_price = $_POST['non_member_ticket_price'];

                    ...and then establish a similar Custom Trigger with an extended calculation, like this:

                    ------------
                    $total_members = $member_ticket_price * $tNG->getColumnValue("transaction_column_no_membertickets");

                    $total_non_members = $non_member_ticket_price * $tNG->getColumnValue("transaction_column_no_nonmembertickets");

                    $total_total = $total_members + $total_non_members;
                    ------------

                    ...and insert $total_total into whatever column

                    I hope my math skills are not completely gone by now, but I think this should work

                    Cheers,
                    Günter Schenk
                    Adobe Community Expert, Dreamweaver
                    • 7. Re: Calculate fields
                      (Laurence_Lewis) Level 1
                      That makes sense, however I will put it in action tomorrow, its 11PM here and after a long day I am calling it a night.

                      thanks for the help which was as usual perfection

                      Laurence