Decimals in calc display details view

jh

Member
Hi

Ive used a calc element in details view to return an else/if value based on another element value. This is working fine.

I have used a mixture of html and placeholders for this calc. It is displaying very nicely however I have realised the placeholder values (which are numbers) are not displaying how I wanted. I think it is only happening on numbers ending '.0'.
For example, if the element value is 25.0, it is showing as 2.4.
If it is 2.0, it is showing as 0.1.
If it is 25.1 it is showing correctly as 25.1.
If it is 2.5, it is showing correctly as 2.5.

The placeholder elements are db joins, with the values decimals set as 11,1. They display like that in a non-calc element.

I am not sure if the problem is that I cant use a calc element to do this or a number formating issue somewhere (I have tried a few different settings with no luck).

Any help would be gratefully received.

Kind Regards
 
Hi,

In my calc element the code I have is:

--------------------------
$ev_ssr = '{object_table___shape_specific_retest_raw}';

if ($ev_ssr ==24 or $ev_ssr==31 or $ev_ssr==18 or $ev_ssr==15){

return ' <div class="row-fluid">
<div class="span7"><b>Diameter (CM):</b>

</div>
<div class="span5">{object_table___length_new}


</div></div>
<div class="row-fluid">
<div class="span7"><b>Height (CM):</b>

</div>
<div class="span5">{object_table___height_new}


</div></div>



';
}
else {
return '
<div class="row-fluid">
<div class="span7"><b>Height (CM):</b>

</div>
<div class="span5">{object_table___height_new}


</div></div>
<div class="row-fluid">
<div class="span7"><b>Length (CM):</b>

</div>
<div class="span5">{object_table___length_new}


</div></div>
<div class="row-fluid">
<div class="span7"><b>Width (CM):</b>

</div>
<div class="span5">{object_table___width_new}


</div></div>




';
}

-----------------------------------------
Basically it shows some fields only if another element has a certain value. It seems to display and work OK, but it is the values (the placeholders) that have problems sometimes, depending on the input.

Thank you for your valuable help as always.

Kind Regards
 
You are comparing the string $ev_ssr against integers and returning a lot more than just one value.
So which of placeholders is showing the wrong value?

{element} may be a complete link (depending on your element settings), try {element_raw}
 
Hi

The placeholders {object_table___length_new} {object_table___height_new} {object_table___width_new} all seem to be returning the wrong value when the value is a number ending '.0'.
So 5.1, 7.1 etc are returning fine, but 5.0, 7.0 etc are returing unexpected results.

I have tried 'raw' but as the values are from dbjoins, it is returning the ID only. Each of the DB joins is a number, set as 11,1 decimal. Is it perhaps something to do with the setting for these numbers?

I have wondered if I can just use javascript to hide/show elements depending on the value of the {object_table___shape_specific_retest_raw} element (which is what I have tried to use this calc for) if there is not a simple solution.

Kind Regards
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top