In my database i have items i am selling, one of the fields is quantity 
which refers to the number of items still available for purchase, what i 
want is for that item not to be displayed when quantity reaches 0. 
Initially i had the items get deleted when quantity is zero until i 
realized that the sales details of that item in the sales table are also 
deleted since it is referenced from the product table where its being 
deleted. I had to come up with a better solution apart from deleting, i 
tried this below, where its colored:

{{for p in products:}}
        {{if p.product_type=="Earrings":}}











*<script>            jQuery(document).ready(function()                      
             {                if (jQuery({{p.amount==0}}))                  
            {                 const id = jQuery(this).data('id');          
      jQuery('#'+id).hide();                              }            });  
      </script><div class="clothes" data-id="{{=p.id}}">*
    <h4 style="color: #ff69b4;">{{=p.name}}</h4>
    <h7 style="color: #ff69b4;">{{=p.amount}} available in stock</h7>
    <h5>
        <span style="color: aqua; font-weight: 
bold;">{{=MoneyFormat(p.price)}}</span>
    </h5>
    <img class="magnify" src="{{=URL('download',args=p.image)}}" 
height="200px"/>
    <br />
    {{=A('REMOVE',callback=URL('cart_callback',vars=dict(id=p.id,action=
'sub')),target='item%s'%p.id,_class='button pill')}} - <span id=
"{{='item%s'%p.id}}" style="font-weight: bold; color: red;">{{=session.cart.
get(p.id,0)}}</span> in cart - {{=A('ADD',callback=URL('cart_callback',vars=
dict(id=p.id,action='add')),target='item%s'%p.id,_class='button pill')}}
    <br />
    <span style="font-size:12px;font-weight: bold; color: #ff69b4;">Click 
the image to enlarge</span>
<br />
</div>
{{pass}}

But this is a desperate move, if *data-id={{=p.id}} *was in a link then 
something would probubly happen, maybe, i feel only a pure python script 
could work here.
* Is there a way i could choose what gets displayed in the view & what 
doesn't get displayed from the database table based on its content using 
only python??*

Regards;

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/6d01df0e-2e1a-43f7-ba68-04488e3016b8%40googlegroups.com.

Reply via email to