<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>
...............
...............
...............
...............
...............
...............
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>
<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 assistRegards;Mostwanted
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/c26be28b-585d-452d-a255-6ba9be30f67b%40googlegroups.com.
<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 {{='' if p.Quantity<10 else 'hidden'}}">Please Refill</span>
</td>
</tr>
{{pass}} On Fri, Sep 13, 2019 at 2:31 PM mostwanted <godir...@gmail.com> wrote: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!
every python code must be enclosed in {{}} also you need a {{pass}} at the end of if-else statement