calc element

Can you please post your essential question here. The thread you are mentioning is to confusing.
 
What I am writing is the essential of post #33 and a summary of the whole thread.

Explanation:
Students and teachers who buy a lesson can pay a price in euro. The total euro element increases when users use sell a lesson or sell books forms and decreases when they add data in buy a lesson and buy books forms.

Elements to use:
Euro to pay (in lessons_to_buy form)
Euro to receive (in lessons_to_sell form)
Total euro (in current_account list)

Euro to pay and Euro to receive are fields filled by the users.
Total euro should be an element showing a balance between euro to pay and euro to receive.

Requirement:
I would need to know how to let work Total euro element.
 
Add a calc element, put in php code returning the total, something like

return (int)'{in lessons_to_buy form}' - (int)'{in lessons_to_sell form}';

Set ajax calculation =yes if the user should see the new total every time he is changing the sell or buy value
 
Hi,
I have tried the code by replacing {in lessons_to_sell form} and {in lessons_to_buy form} with placeholders, but it doesn't work.
I have created two forms: "compra" and "vendi" and both of them contain an element called euro and with number format (integer). A third table contains the calc element with the php code.
I am attaching the php code that I have written into the calc element.
 

Attachments

  • calc element.jpg
    calc element.jpg
    34 KB · Views: 192
Please let me know if my procedure coincides with your suggestion.
The field (calc element) into the form (third table) is 0 and the list shows: No records...
 
Are both those elements on the same form? In other words, have you joined the lists?

Placeholders only work for elements which are displayed in the form they are being used in.

-- hugh
 
I have just added two database join elements in Totale table. Now there is a join element which points to the euro to pay element and a join element which points to the euro to receive element.
Value: id [recommended]
label: euro to pay (or to receive)

Both the database join elements are hidden.
By using these settings it doesn't work. The totale list is still showing: No records....
 
The totale list is still showing: No records....
???
What does the list have to do with the calc element?
Both the database join elements are hidden.
What are they showing if they are not hidden? Screenshot of your form? Screenshot of the elements of your form?
 
Please let me know if these snapshots answer to the questions.
 

Attachments

  • euro - compra.jpg
    euro - compra.jpg
    38.8 KB · Views: 185
  • euro vendi.jpg
    euro vendi.jpg
    38.3 KB · Views: 180
  • euro_c.jpg
    euro_c.jpg
    67.2 KB · Views: 186
  • euro_v.jpg
    euro_v.jpg
    69 KB · Views: 182
  • totale.jpg
    totale.jpg
    59.7 KB · Views: 184
In the calc element you can only use placeholders of elements of the form the calc is belonging to, so something like
return = (int)'{totale___euro_v}' - (int)'{totale___euro_c}';

The totale list will show records if you are adding some:
In totale list click add, select euro_c from dropdown, select euro_v from dropdown, save.
 
In this way, it seems that users can select the values in euro_c and in euro_v (of totale form) to sum. Is there a way to sum every value added in the other 2 forms without that the user can choose what values to sum and what not?
If necessary the user could add a record in totale list to know the sums (no problem for that), but it should be obliged to know the sums of every values submitted in the other 2 forms.
Is there a way to do that?
Please let me know if this makes sense.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top