How hide 0 in a numeric/currency form field ?

I got a numeric/currency field that show prices of products.
I need to hide it when the case of price is ‘0’ (zero) becouse it can be ambiguos in same cases… (don’t tell me why…). They say don’t gift products…:wink:

Something from this

ITEM1____100.25
ITEM2____60.00
ITEM3____0.00
ITEM4____55.00
ITEM5____0.00

to

ITEM1____100.25
ITEM2____60.00
ITEM3____
ITEM4____55.00
ITEM5____

Thanks

You could use javascript I guess…

Or SQL.

In the select instead of fieldname you could use something like:

(IF(fieldname = 0, “”, fieldname)) as fieldname_no_zero

Not sure at all about the syntax, but it’s definitely doable in SQL.

EDIT- jscript should be safer as it works on the display only and maybe an empty string could break some calculations

Thanks !!!
It seems easier for me that Js… (I don’t know it )
Do you think that in form field it shows a blank space instead of 0 also if the form field is a Numeric ?

In addition to robydago you an use php.

Grid: onRecord
Form: onLoadRecord

{price} = ({price} == 0? “” );

jsb

giovannino,
I have no idea.
Also as I’ve added to my previous post: jscript should be safer as it works on the display only and maybe an empty string could break some calculations.

You coud also try PHP :
ONLOAD EVENT

if ( {fieldname} == 0) 
{
 {fieldname} = "";
} 

EDIT - as always… JSB was quicker!

Hi JSB,

I did this but sintax probably need a fix… :wink:

{PriceUnit} = ({PriceUnit} == 0? "" );

Error…Parse error: syntax error, unexpected ‘)’ Line 2422

code:

2422 $this->priceunit = ($this->priceunit == 0? “” );
2423 $this->sc_temp_glo_UnitPrice = 0 ;
2424 $this->sc_temp_glo_CurrencyID= 1 ;

Try the long statement.


if({PriceUnit} == 0)
{
    {PriceUnit} = '';
}


jsb

That’s it !!! ;-)))))

[QUOTE=giovannino;38790]Hi JSB,

I did this but sintax probably need a fix… :wink:

{PriceUnit} = ({PriceUnit} == 0? "" );

Error…Parse error: syntax error, unexpected ‘)’ Line 2422

code:

2422 $this->priceunit = ($this->priceunit == 0? “” );
2423 $this->sc_temp_glo_UnitPrice = 0 ;
2424 $this->sc_temp_glo_CurrencyID= 1 ;[/QUOTE]

AFAIR ternary operand needs to be complete
{PriceUnit} = ({PriceUnit} == 0? “” : {PriceUnit} );

Hey Giu,
good trick !!!

Thanks again !