We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25483
    • 741 Posts
    !! I will use other values as example !!
    I need to create a form with 3 numeric values.

    If the values from field1 and field2 together are

    • less then 10 it should do a sum of $totalvalue*2,4
    • more then 10 but less then 15 it should do a sum of $totalvalue*3,8
    • more then 20 it should do a sum of $totalvalue*5


    Then after the sum has been done there is to be a sum of $resultofsum+$field3
    This will get a $result with the total of the sum which will be displayed as result on submitting the form. There will be no mail sent, just making above sums

    Can I do this with eForm? Or is there a better way to do this?
    I think I need a action in eForm which calls a php code with a if or switch-statement to return the right value.
      with regards,

      Ronald Lokers
      'Front-end developer' @ h2o Media

      • 30223
      • 1,010 Posts
      You can certainly use eForm for this and besides loading some unneeded code (the email handling) its certainly no overkill. You still have the advantage of eForm’s form validation should you choose so.

      You can switch of any email sending with the &nomail (or was it &noemail) parameter.

      You can build an event function for the eFormOnBeforeMailSent event which does all the calculations and set’s placeholders in the $fields array for display. There are plenty of examples here in the forums and in the snippets/eform/docs/eform.htm documentation on how to work with eForm’s events.
        • 25483
        • 741 Posts
        Thanks for you comment!

        I am stuck with the code, I get this error after submitting the form:

        Fatal error: Call to undefined function HypoFormBerekenen() in /home/xxxdev/domains/dev.xxx.nl/public_html/071801-raadhof/assets/snippets/eform/eform.inc.php on line 386


        I use this call on the page:

        [[HypoFormBerekenen]] [!eForm? &formid=`HypoFormNL` &tpl=`HypoFormNL` &thankyou=`HypoFormThankyouNL` &invalidClass=`error` &requiredClass=`succes` &noemail=`1` &eFormOnBeforeMailSent=`HypoFormBerekenen`!] 


        And this is the snippet HypoFormBerekenen:

        <?php
        //code die gebruikt wordt om een indicatie te geven voor de hypotheek!
        
        	function HypoFormBerekenen( &$fields ){
                        $totaal_bruto = $fields['bruto_jaarinkomen'] + $fields['bruto_jaarinkomen2'];
                        $fields['resultaat']= $totaal_bruto;
        		return true;
        	}
        ?>


        What do i do wrong?

          with regards,

          Ronald Lokers
          'Front-end developer' @ h2o Media

          • 30223
          • 1,010 Posts
          If php isn’t seeing the function my guess would be a caching issue. Refresh the site and check the caching setting for the document. You may have to adjust the snippet brackets accordingly. Otherwise I’d have no idea so quickly.
            • 25483
            • 741 Posts
            just shoot me now shocked

            I forgot about the cache, now it works like a charm grin
              with regards,

              Ronald Lokers
              'Front-end developer' @ h2o Media

              • 10449
              • 956 Posts
              Actually, if you don’t need to send anything to the server, nor query any values via PHP/mySQL, then why not simply use Javascript?
                • 25483
                • 741 Posts
                Quote from: ganeshXL at Oct 15, 2008, 06:58 PM

                Actually, if you don’t need to send anything to the server, nor query any values via PHP/mySQL, then why not simply use Javascript?

                I am not a JavaScript pro and I want to keep the clientside code as clean as possible smiley

                I just expanded the code to fit my needs and it works great now! Thanks for the help.
                  with regards,

                  Ronald Lokers
                  'Front-end developer' @ h2o Media