Announcement

Collapse
No announcement yet.

How hide 0 in a numeric/currency form field ?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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...;-)

    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

  • #2
    You could use javascript I guess...

    Comment


    • #3
      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
      Last edited by robydago; 07-21-2015, 07:32 AM.

      Comment


      • #4
        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 ?

        Comment


        • #5
          In addition to robydago you an use php.

          Grid: onRecord
          Form: onLoadRecord

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

          jsb

          Comment


          • #6
            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
            Code:
            if ( {fieldname} == 0) 
            {
             {fieldname} = "";
            }

            EDIT - as always.... JSB was quicker!
            Last edited by robydago; 07-21-2015, 09:51 AM.

            Comment


            • #7
              Hi JSB,

              I did this but sintax probably need a fix... ;-)

              {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 ;

              Comment


              • #8
                Try the long statement.

                Code:
                if({PriceUnit} == 0)
                {
                    {PriceUnit} = '';
                }
                jsb

                Comment


                • #9
                  That's it !!!! ;-)))))

                  Comment


                  • #10
                    Originally posted by giovannino View Post
                    Hi JSB,

                    I did this but sintax probably need a fix... ;-)

                    {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 ;
                    AFAIR ternary operand needs to be complete
                    {PriceUnit} = ({PriceUnit} == 0? "" : {PriceUnit} );
                    /Giuseppe

                    Professional Scriptcase Services
                    Some Customers opinions

                    Comment


                    • #11
                      Hey Giu,
                      good trick !!!

                      Thanks again !

                      Comment

                      Working...
                      X