Forums

Form Calculations Needed

john2aus 19 Sep, 2009
Hi,

I have been putting ChronoForms to good use lately. At the moment I am at a hurdle that I need to jump with the help of a few experienced people🙂

I have created a form (see it here as a single web page not connected to Joomla: http://www.test1.ausalive.com/a/). What I need to do is calculate the quote price based on what the user enters. (Not this is similar to what was done in this thread http://www.chronoengine.com/forums.html?cont=posts&f=2&t=13273&start=0&hilit=calculations).

The difference is that I want my form to:
[list]
  • Update instantly as the user enters data,
  • [/list]
    [list]
  • Be able to email all the data and totals when the Submit Quote button is pressed.
  • [/list]

    I would prefer to have the calculations hidden from the user, but if this is harder in any way I would just go for doing it with Javascript.

    Does Chronoforms support such a thing - or does PHP code need to be used? Your support is much appreciated and if this is a bigger job than I think I will be happy to pay for the work done on my site.


    Thank a lot,
    John
    GreyHead 19 Sep, 2009
    Hi John,

    There are three ways of doing this - each with pros and cons:

    a) JavaScript: To do the sums on this page probably 10-20 lines of code. Display the result to the customer and save it in a hidden field to have it ready to email/save to db.
    Pro: Instant calculation, easy to do
    Con: Possibly visible to a nosy visitor

    b) AJAX: Basically JavaScript in the browser asking the server for an answer. Probably 100 lines of code and noticably slower than pure JavaScript but still nearly instant. (AJAX is usually reserved for much heavier weight processes than this.)
    Pro: Concealed calculation
    Con: More complex to code & slower.

    c) Server Side calculation: Calculate server-side and refresh the page. Pretty simple to do - probably 10 lines of code.
    Pro: Simple to do, concealed calculation
    Con: Much slower response.

    With any of these three you can preserve the results and email & save them.

    Bob
    john2aus 21 Sep, 2009
    Hi Bob,

    I think JavaScript would be the way to go as it is simple and time effective. What is the next step to implementing this ?

    Note: I do not have any experience with JavaScript.
    This topic is locked and no more replies can be posted.