El viernes, 13 de septiembre de 2019, 9:31:23 (UTC+2), mostwanted escribió:
>
> This conditional statement should be simple & execute without any issues, 
> I have created a point of Sale system, in a view it shows all the items & 
> their available quantities, what i want is that when a product's quantity 
> goes below 10 the quantity figure should turn red & a please refill message 
> should be displayed but i am not getting this, the if condition is ignored 
> altogether, only the else statement is executed!
>
> VIEW CODE
> <style>
>     .refill
>     {
>     display: none;
>     color: red;
>     font-weight: bold;
>     padding: 2px;
>     }
> </style>
> {{for idx, p in enumerate(products, start=1):}}
>     
>   <tr id="soldItems">
>       <script>
>         $(document).ready(function()
>                                {
>             if({{=p.Quantity}} <10)
>             {
>             $('span.quantity').css({'color':'red'});
>             $('.refill').show();
>             }
>             else
>             {
>             $('span.quantity').css({'color':'green'});
>             $('.refill').hide();
>             }
>         });
>     </script>
> {{pass}}      
> <td><span style="font-weight: bold; font-size: 15px;">{{=idx}}</span></td>
>       <td><span class="quantity" style="font-weight: bold; font-size: 15px
> ;">{{=p.Quantity}}</span> <span class="refill">Please Refill</span></td>
> ...............
> ...............
> ...............
> ...............
> ...............
> ...............
>
> Please assist
>
> Regards;
>
>  

> Mostwanted
>

Maybe this can help

<style>
    .refill {
        color: red;
        font-weight: bold;
        padding: 2px;
    }
    .bold15 {
        font-weight: bold;
        font-size: 15px;
    }
    .red {
        color: red;
    }
    .green {
        color: green;
    }
</style>
{{for idx, p in enumerate(products, start=1):}}
  <tr id="soldItems">
    <td>
        <span class="bold15">{{=idx}}</span>
    </td>
    <td>
        <span class="bold15 {{='red' if p.Quantity<10 else 
'green'}}">{{=p.Quantity}}</span>
        <span class="refill {{='hidden' if p.Quantity<10 else ''}}">Please 
Refill</span>
    </td>
  </tr>   
{{pass}}  

Regards

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/95e67ae9-5dbe-4200-b139-57a46ab60280%40googlegroups.com.

Reply via email to