Me again with a calc question

Folks

I have a dropdown with the values of 0 and 25 and a cascading element that displays the cost from a database join element - all works as expected - I want the value from the drop down and the CDD to be added together in a calc element. The code I have is as below but is returns ?0.00

PHP:
$x=('{bookings___Furnished}' + '{bookings___Inventory_Cost}');
return '?'.number_format($x,2);

Can someone help please? :)
 
I can't see anything obvious.

Maybe try breaking it down to test everything, i.e just do a return '{bookings___Furnished}'; to see if it's picking up what you expect. Then try return '{bookings___Inventory_Cost}';
 
I suppose this is the CDD? How is it rendered ? If it is as a dropdown, you should also add _raw at the end, but I have a feeling this is some multiselection CDD (checkboxes?), so the values are stored by this element are NULL and the actual value is in a seperate table.
I don't know whether you use a placeholder to retreive the value. You may have to run a MySQL query in the calc element to feed your calculation.
But Rob or Hugh should confirm this.
 
Hi JF

The element that is causing the issue is indeed from a dropdown cdd that comes from the table but adding raw at the end does not help :)

I'm sure I have done this before?
 
I think the value returned by the CDD element is an array, that's why you can't add it directly.
I would try this to see what it retruns:
PHP:
$cost = '{bookings___Inventory_Cost_raw}';
return $cost[0];
 
I just thought I would report back - I have managed to do this by doing the following. I have added some CDD elements that are hidden which load the data from a database join and the data they load is from some new columns in the database with exactly the same data as I am trying to calculate

I have then added the columns together using _raw in the relevant element names

See Here (Click the button top left to reveal the form)

A crude way I'm sure but it works for me :)

Thanks for everyone's help
 
Sorry I didn't follow my answer up, got side tracked with a few other things.

Well it looks like it's working but your first option seems to be posting data twice, (looking at firebug). I can't say if this is 100% accurate or not without seeing all the other bits. :)
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top