Did you see this?

http://vimeo.com/20768689

The functionality you need is implemented as an example via ajax.

Massimo

On Apr 25, 11:46 am, JoshC <[email protected]> wrote:
> Dear Friends,
>
> As you may recall, I wrote before mentioning that I am working on a
> project for a databases class (an e-store). We were successful at
> implementing the model and some of the functions and views. However,
> we are stuck trying to figure out how to implement the following types
> of requirement:
>
> [1] generate a list of the rows of a table and append a text field and
> submit button which adds a quantity of the item to the cart
>      -- the cart is just a simple table which holds item number, qty,
> and user id. The records matching auth.user_id are just dumped at the
> bottom to show the cart.
>
> [2] generate a list of the rows of a table and put a text field that
> can update one of the fields
>
> This is the non-functional code with which I tried to accomplish [1]:
> --------------function
> def category_toy():
>     toy = db(db.inventory.type=='Toy').select()
>     cart = db((db.cart.id>0)&(db.cart.uid == auth.user_id)).select()
>     form=FORM('Add quantity to cart:', INPUT(_name='qty'),
> INPUT(_type='submit'))
>     return dict(toy=toy, cart=cart, form=form)
> ------------------------view
>
> <ul>
> {{for i in toy:}}
>
> {{=LI(H4("Item: ", i.item, ", Quantity: ",i.qty))}}
> <!--{{=H3(A(' Add to cart', _href=URL('add_to_cart',
> vars=dict(item=i.item, page=request.function))))}}-->
>
> {{pass}}
> </ul>
>
> The commented out part is where I tried using a link to another
> function, but I couldn't get the dict to work right. The plan was then
> to redirect back to the form page.
>
> I'm probably missing something obvious, but I've been studying the
> book, and haven't figured it out. Advice would be much appreciated.
>
> Yours,
> Josh Cason

Reply via email to